diff --git a/Outpost/Features/Account/SettingsView.swift b/Outpost/Features/Account/SettingsView.swift index 48570f7..13de716 100644 --- a/Outpost/Features/Account/SettingsView.swift +++ b/Outpost/Features/Account/SettingsView.swift @@ -144,6 +144,18 @@ struct SettingsView: View { onCancel: { pickedPhoto = nil } ) } + // The session only holds whatever was fetched at sign-in/launch — + // a name (or avatar) changed elsewhere (the Outline web app, say) + // never reaches it on its own. Refetching every time this page + // opens, rather than only once per app launch, is what makes that + // show up without having to quit and relaunch. + .task { + editableName = session.userName ?? "" + await refreshProfile() + } + .onChange(of: session.userName) { _, newValue in + editableName = newValue ?? "" + } } private var avatarRow: some View { @@ -199,7 +211,6 @@ struct SettingsView: View { } } .frame(maxWidth: 420, alignment: .leading) - .task { editableName = session.userName ?? "" } } private var emailRow: some View { @@ -527,6 +538,12 @@ struct SettingsView: View { // MARK: - Profile actions + private func refreshProfile() async { + guard let apiClient = session.apiClient else { return } + guard let fresh = try? await apiClient.currentUser() else { return } + session.applyUpdatedProfile(fresh) + } + private func pickPhoto() { let panel = NSOpenPanel() panel.allowedContentTypes = [.png, .jpeg, .heic, .image]