diff --git a/CHANGELOG.md b/CHANGELOG.md index 8eee349e3..d0adede57 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Release Notes +- Fixed a crash that could occur while Nos was in the background. - Fixed a bug where Nos sometimes wouldn't reconnect to relays. - Added nos.lol to the default relay list for new accounts and removed relay.snort.social. - Show quoted notes in note cards. diff --git a/Nos/Service/PushNotificationService.swift b/Nos/Service/PushNotificationService.swift index a7bfcca49..28ed2aa15 100644 --- a/Nos/Service/PushNotificationService.swift +++ b/Nos/Service/PushNotificationService.swift @@ -51,6 +51,7 @@ import Combine @Dependency(\.persistenceController) private var persistenceController @Dependency(\.router) private var router @Dependency(\.analytics) private var analytics + @Dependency(\.crashReporting) private var crashReporting @Dependency(\.userDefaults) private var userDefaults @Dependency(\.currentUser) private var currentUser @@ -91,8 +92,13 @@ import Combine cacheName: nil ) notificationWatcher?.delegate = self - try? await modelContext.perform { - try self.notificationWatcher?.performFetch() + await modelContext.perform { [weak self] in + do { + try self?.notificationWatcher?.performFetch() + } catch { + Log.error("Error watching notifications:") + self?.crashReporting.report(error) + } } let userMentionsFilter = Filter(