From cb8bbd53c4b1e9fca248f7e66994be540b2ed3cd Mon Sep 17 00:00:00 2001 From: psavarmattas Date: Sat, 15 Aug 2026 16:31:40 +0100 Subject: [PATCH] fix(profile): refresh from the server every time the page opens MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SessionStore only ever populated from auth.info once per app launch — a name (or avatar) changed elsewhere, like Outline's web app, never reached it until a full quit-and-relaunch. Profile now refetches via currentUser() every time it's opened and applies the result, same as any live edit made from this app already does. Fails silently offline, same as everything else that needs a live read. --- Outpost/Features/Account/SettingsView.swift | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) 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]