Stop ProfileManager when app is being backgrounded

This should prevent RUNNINGBOARD 0xdead10cc crashes related to
ProfileManager and app background states.

Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
This commit is contained in:
Daniel D’Aquino
2025-09-26 13:01:05 -07:00
parent 258d08723f
commit fe62aea08a
2 changed files with 10 additions and 10 deletions

View File

@@ -47,7 +47,7 @@ class NostrNetworkManager {
self.profilesManager = ProfilesManager(subscriptionManager: reader, ndb: delegate.ndb)
}
// MARK: - Control functions
// MARK: - Control and lifecycle functions
/// Connects the app to the Nostr network
func connect() {
@@ -60,6 +60,12 @@ class NostrNetworkManager {
self.pool.disconnect()
}
func close() async {
await self.reader.cancelAllTasks()
await self.profilesManager.stop()
pool.close()
}
func ping() {
self.pool.ping()
}
@@ -137,14 +143,6 @@ class NostrNetworkManager {
print("damus-donation donating...")
WalletConnect.pay(url: nwc, pool: self.pool, post: self.postbox, invoice: invoice, zap_request: nil, delay: nil)
}
// MARK: - App lifecycle functions
func close() async {
await self.reader.cancelAllTasks()
pool.close()
}
}

View File

@@ -49,9 +49,11 @@ extension NostrNetworkManager {
}
}
func stop() {
func stop() async {
self.subscriptionSwitcherTask?.cancel()
self.profileListenerTask?.cancel()
try? await self.subscriptionSwitcherTask?.value
try? await self.profileListenerTask?.value
}
private func restartProfileListenerTask() {