Reload the app's task lists when the event stream reconnects
This commit is contained in:
@@ -95,6 +95,7 @@ final class Store {
|
||||
@ObservationIgnored private var taskReloads: Set<String> = []
|
||||
@ObservationIgnored private var taskReloadAgain: Set<String> = []
|
||||
@ObservationIgnored private var terminalChanges = 0
|
||||
@ObservationIgnored private var streamOpens = 0
|
||||
@ObservationIgnored private var globalStream: EventStream?
|
||||
@ObservationIgnored private var leadStream: EventStream?
|
||||
@ObservationIgnored private var stopped = false
|
||||
@@ -698,15 +699,44 @@ final class Store {
|
||||
}, onState: { [weak self] up in
|
||||
self?.connected = up
|
||||
if up {
|
||||
self?.spawn("load terminals") {
|
||||
try await self?.loadTerminals()
|
||||
}
|
||||
self?.resync()
|
||||
self?.paneFocus.reconnected()
|
||||
reconnected()
|
||||
}
|
||||
}, onReady: {})
|
||||
}
|
||||
|
||||
// A reload an event triggers can fail while the connection drops, and the stream won't replay that event, so each reconnect reloads everything events keep current.
|
||||
private func resync() {
|
||||
spawn("load terminals") {
|
||||
try await self.loadTerminals()
|
||||
}
|
||||
streamOpens += 1
|
||||
if streamOpens == 1 {
|
||||
return
|
||||
}
|
||||
spawn("load me") {
|
||||
try await self.loadMe()
|
||||
}
|
||||
spawn("load projects") {
|
||||
try await self.loadProjects()
|
||||
}
|
||||
spawn("load inbox") {
|
||||
try await self.loadInbox()
|
||||
}
|
||||
spawn("load lead sessions") {
|
||||
try await self.loadLeadSessions()
|
||||
}
|
||||
spawn("load summary reads") {
|
||||
try await self.loadSummaryReads()
|
||||
}
|
||||
for (_, task) in activeTasks() {
|
||||
spawn("load sessions") {
|
||||
try await self.loadSessions(task.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func leadHasOlder() -> Bool {
|
||||
leadFeed.ready && leadMore
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user