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:
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user