mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-11-29 02:39:13 +00:00
fix(menubar): keep refresh timer alive across sleep
The sleep handler tore down the DispatchSource timer; a missed wake notification then left it nil forever, stranding the refresh loop. Cancel only in-flight tasks and let the kernel-paused timer resume.
This commit is contained in:
parent
d7a4048b9f
commit
ea64dca52e
1 changed files with 6 additions and 2 deletions
|
|
@ -161,6 +161,12 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSPopoverDelegate {
|
|||
}
|
||||
|
||||
private func prepareRefreshPipelineForSleep() {
|
||||
// Cancel only in-flight work so a fetch started before sleep cannot
|
||||
// apply a stale result after wake. The DispatchSource timer is paused
|
||||
// by the kernel during sleep and fires normally on wake, so we leave
|
||||
// it running — tearing it down here was the stranding bug: a missed
|
||||
// wake notification left refreshTimer nil forever. The 5s rate limiter
|
||||
// and single-flight forceRefreshTask guard absorb the wake burst.
|
||||
forceRefreshTask?.cancel()
|
||||
forceRefreshTask = nil
|
||||
forceRefreshStartedAt = nil
|
||||
|
|
@ -173,8 +179,6 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSPopoverDelegate {
|
|||
statusPayloadRefreshStartedAt = nil
|
||||
statusPayloadRefreshGeneration &+= 1
|
||||
store.resetLoadingState()
|
||||
stopRefreshTimer()
|
||||
refreshLoopHeartbeatAt = .distantPast
|
||||
lastRefreshTime = .distantPast
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue