Reload service on current profile update

This commit is contained in:
世界
2024-11-29 14:40:55 +08:00
parent 96cfbd5b09
commit fe7dd4322f
2 changed files with 20 additions and 1 deletions
+19 -1
View File
@@ -13,8 +13,26 @@ public extension Profile {
if let error {
throw error
}
try write(remoteContent)
lastUpdated = Date()
try await ProfileManager.update(self)
do {
let oldContent = try read()
if oldContent == remoteContent {
return
}
} catch {}
try write(remoteContent)
try await onProfileUpdated()
}
nonisolated func onProfileUpdated() async throws {
if await SharedPreferences.selectedProfileID.get() == id {
if let profile = try? await ExtensionProfile.load() {
if profile.status == .connected {
try LibboxNewStandaloneCommandClient()!.serviceReload()
}
}
}
}
}