fix(profile): refresh from the server every time the page opens

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.
This commit is contained in:
2026-08-15 16:31:40 +01:00
parent 90df5f056d
commit cb8bbd53c4
+18 -1
View File
@@ -144,6 +144,18 @@ struct SettingsView: View {
onCancel: { pickedPhoto = nil } 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 { private var avatarRow: some View {
@@ -199,7 +211,6 @@ struct SettingsView: View {
} }
} }
.frame(maxWidth: 420, alignment: .leading) .frame(maxWidth: 420, alignment: .leading)
.task { editableName = session.userName ?? "" }
} }
private var emailRow: some View { private var emailRow: some View {
@@ -527,6 +538,12 @@ struct SettingsView: View {
// MARK: - Profile actions // 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() { private func pickPhoto() {
let panel = NSOpenPanel() let panel = NSOpenPanel()
panel.allowedContentTypes = [.png, .jpeg, .heic, .image] panel.allowedContentTypes = [.png, .jpeg, .heic, .image]