mirror of
https://github.com/ichmagmaus111/ghostgram.git
synced 2026-04-29 03:15:59 +02:00
fix(ghostgram): fix Always Online + implement Ghost Mode mutual exclusion
Bugs fixed: - Always Online had no effect after toggle — updatePresence was only called on app focus changes, not on settings changes. Fixed by subscribing to MiscSettingsManager notifications in AccountPresenceManagerImpl. - Ghost Mode + Always Online conflict: if Ghost Mode was enabled, the early return in updatePresence completely blocked Always Online logic. Changes: - ManagedAccountPresence: priority chain Always Online > Ghost Mode > default. Subscribes to GhostMode/MiscSettings notifications, refreshes presence immediately on any change. 30s keep-alive timer for Always Online. - GhostModeManager: enabling Ghost Mode auto-disables alwaysOnline via disableAlwaysOnlineForMutualExclusion(). No recursion via guard flag. - MiscSettingsManager: enabling alwaysOnline auto-disables Ghost Mode via disableForMutualExclusion(). No recursion via guard flag. - MiscController: subscribes to GhostModeManager notifications to refresh UI when Ghost Mode is auto-disabled by Always Online. - GhostModeController: subscribes to MiscSettings notifications to refresh UI when Ghost Mode is auto-disabled by Always Online.
This commit is contained in:
@@ -300,6 +300,28 @@ public func ghostModeController(context: AccountContext) -> ViewController {
|
||||
}
|
||||
)
|
||||
|
||||
// Refresh UI when Always Online is enabled externally and auto-disables Ghost Mode —
|
||||
// the isEnabled flip happens in GhostModeManager from MiscSettingsManager context,
|
||||
// so we need to pull fresh values from the manager.
|
||||
let miscSettingsChangedSignal: Signal<Void, NoError> = Signal { subscriber in
|
||||
let observer = NotificationCenter.default.addObserver(
|
||||
forName: MiscSettingsManager.settingsChangedNotification,
|
||||
object: nil,
|
||||
queue: .main
|
||||
) { _ in
|
||||
updateState { state in
|
||||
state.isEnabled = GhostModeManager.shared.isEnabled
|
||||
state.hideReadReceipts = GhostModeManager.shared.hideReadReceipts
|
||||
state.hideStoryViews = GhostModeManager.shared.hideStoryViews
|
||||
state.hideOnlineStatus = GhostModeManager.shared.hideOnlineStatus
|
||||
state.hideTypingIndicator = GhostModeManager.shared.hideTypingIndicator
|
||||
state.forceOffline = GhostModeManager.shared.forceOffline
|
||||
}
|
||||
}
|
||||
return ActionDisposable { NotificationCenter.default.removeObserver(observer) }
|
||||
}
|
||||
let _ = miscSettingsChangedSignal.start()
|
||||
|
||||
let signal = combineLatest(
|
||||
context.sharedContext.presentationData,
|
||||
statePromise.get()
|
||||
|
||||
Reference in New Issue
Block a user