mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:31:27 +00:00
Combine the user's own display name/avatar into a single profile.
This is in preparation for adding the user status fields into the profile.
This commit is contained in:
@@ -34,12 +34,10 @@ enum SettingsScreenSecuritySectionMode {
|
||||
|
||||
struct SettingsScreenViewState: BindableState {
|
||||
var deviceID: String?
|
||||
var userID: String
|
||||
var userProfile: UserProfile
|
||||
var showLinkNewDeviceButton: Bool
|
||||
var accountProfileURL: URL?
|
||||
var showAccountDeactivation: Bool
|
||||
var userAvatarURL: URL?
|
||||
var userDisplayName: String?
|
||||
var showDeveloperOptions: Bool
|
||||
|
||||
var securitySectionMode = SettingsScreenSecuritySectionMode.none
|
||||
|
||||
@@ -24,7 +24,7 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo
|
||||
self.appSettings = appSettings
|
||||
|
||||
super.init(initialViewState: .init(deviceID: userSession.clientProxy.deviceID,
|
||||
userID: userSession.clientProxy.userID,
|
||||
userProfile: userSession.clientProxy.userProfilePublisher.value,
|
||||
showLinkNewDeviceButton: appSettings.linkNewDeviceEnabled,
|
||||
showAccountDeactivation: userSession.clientProxy.canDeactivateAccount,
|
||||
showDeveloperOptions: appSettings.developerOptionsEnabled,
|
||||
@@ -41,14 +41,9 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo
|
||||
.weakAssign(to: \.state.showLinkNewDeviceButton, on: self)
|
||||
.store(in: &cancellables)
|
||||
|
||||
userSession.clientProxy.userAvatarURLPublisher
|
||||
userSession.clientProxy.userProfilePublisher
|
||||
.receive(on: DispatchQueue.main)
|
||||
.weakAssign(to: \.state.userAvatarURL, on: self)
|
||||
.store(in: &cancellables)
|
||||
|
||||
userSession.clientProxy.userDisplayNamePublisher
|
||||
.receive(on: DispatchQueue.main)
|
||||
.weakAssign(to: \.state.userDisplayName, on: self)
|
||||
.weakAssign(to: \.state.userProfile, on: self)
|
||||
.store(in: &cancellables)
|
||||
|
||||
userSession.sessionSecurityStatePublisher
|
||||
@@ -86,8 +81,7 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo
|
||||
.store(in: &cancellables)
|
||||
|
||||
Task {
|
||||
await userSession.clientProxy.loadUserAvatarURL()
|
||||
await userSession.clientProxy.loadUserDisplayName()
|
||||
await userSession.clientProxy.loadUserProfile()
|
||||
await state.accountProfileURL = userSession.clientProxy.accountURL(action: .profile)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,18 +51,18 @@ struct SettingsScreen: View {
|
||||
context.send(viewAction: .userDetails)
|
||||
} label: {
|
||||
HStack(spacing: 12) {
|
||||
LoadableAvatarImage(url: context.viewState.userAvatarURL,
|
||||
name: context.viewState.userDisplayName,
|
||||
contentID: context.viewState.userID,
|
||||
LoadableAvatarImage(url: context.viewState.userProfile.avatarURL,
|
||||
name: context.viewState.userProfile.displayName,
|
||||
contentID: context.viewState.userProfile.id,
|
||||
avatarSize: .user(on: .settings),
|
||||
mediaProvider: context.mediaProvider)
|
||||
.accessibilityHidden(true)
|
||||
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
Text(context.viewState.userDisplayName ?? "")
|
||||
Text(context.viewState.userProfile.displayName ?? "")
|
||||
.font(.compound.headingMD)
|
||||
.foregroundColor(.compound.textPrimary)
|
||||
Text(context.viewState.userID)
|
||||
Text(context.viewState.userProfile.id)
|
||||
.font(.compound.bodySM)
|
||||
.foregroundColor(.compound.textSecondary)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user