Skip to content

Commit fe7dd43

Browse files
committed
Reload service on current profile update
1 parent 96cfbd5 commit fe7dd43

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

ApplicationLibrary/Views/Profile/EditProfileView.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ public struct EditProfileView: View {
166166
#else
167167
try await ProfileUpdateTask.configure()
168168
#endif
169+
try await profile.onProfileUpdated()
169170
} catch {
170171
alert = Alert(error)
171172
return

Library/Database/Profile+Update.swift

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,26 @@ public extension Profile {
1313
if let error {
1414
throw error
1515
}
16-
try write(remoteContent)
1716
lastUpdated = Date()
1817
try await ProfileManager.update(self)
18+
do {
19+
let oldContent = try read()
20+
if oldContent == remoteContent {
21+
return
22+
}
23+
} catch {}
24+
try write(remoteContent)
25+
try await onProfileUpdated()
26+
}
27+
28+
nonisolated func onProfileUpdated() async throws {
29+
if await SharedPreferences.selectedProfileID.get() == id {
30+
if let profile = try? await ExtensionProfile.load() {
31+
if profile.status == .connected {
32+
try LibboxNewStandaloneCommandClient()!.serviceReload()
33+
}
34+
}
35+
}
1936
}
37+
2038
}

0 commit comments

Comments
 (0)