Remove Store.save calls

This commit is contained in:
Philipp Heckel 2023-11-14 16:00:48 -05:00
parent de92923604
commit 080243ae17
3 changed files with 2 additions and 26 deletions

View file

@ -97,23 +97,6 @@ extension AppDelegate: UNUserNotificationCenterDelegate {
) { ) {
let userInfo = notification.request.content.userInfo let userInfo = notification.request.content.userInfo
Log.d(tag, "Notification received via userNotificationCenter(willPresent)", userInfo) Log.d(tag, "Notification received via userNotificationCenter(willPresent)", userInfo)
guard let message = Message.from(userInfo: userInfo) else {
Log.w(tag, "Cannot convert userInfo to message", userInfo)
completionHandler([])
return
}
let store = Store.shared
let baseUrl = userInfo["base_url"] as? String ?? Config.appBaseUrl
guard let subscription = store.getSubscription(baseUrl: baseUrl, topic: message.topic) else {
Log.w(tag, "Subscription \(topicUrl(baseUrl: baseUrl, topic: message.topic)) unknown")
completionHandler([])
return
}
Store.shared.save(notificationFromMessage: message, withSubscription: subscription)
completionHandler([[.banner, .sound]]) completionHandler([[.banner, .sound]])
} }
@ -131,17 +114,9 @@ extension AppDelegate: UNUserNotificationCenterDelegate {
return return
} }
let store = Store.shared
let baseUrl = userInfo["base_url"] as? String ?? Config.appBaseUrl let baseUrl = userInfo["base_url"] as? String ?? Config.appBaseUrl
let action = message.actions?.first { $0.id == response.actionIdentifier } let action = message.actions?.first { $0.id == response.actionIdentifier }
guard let subscription = store.getSubscription(baseUrl: baseUrl, topic: message.topic) else {
Log.w(tag, "Subscription \(topicUrl(baseUrl: baseUrl, topic: message.topic)) unknown")
completionHandler()
return
}
Store.shared.save(notificationFromMessage: message, withSubscription: subscription)
// Show current topic // Show current topic
if message.topic != "" { if message.topic != "" {
selectedBaseUrl = topicUrl(baseUrl: baseUrl, topic: message.topic) selectedBaseUrl = topicUrl(baseUrl: baseUrl, topic: message.topic)

View file

@ -26,6 +26,7 @@ class NotificationsObservable: NSObject, ObservableObject {
super.init() super.init()
do { do {
Log.d(tag, "Fetching notifications")
try self.fetchedResultsController.performFetch() try self.fetchedResultsController.performFetch()
self.notifications = self.fetchedResultsController.fetchedObjects ?? [] self.notifications = self.fetchedResultsController.fetchedObjects ?? []
} catch { } catch {

View file

@ -22,7 +22,7 @@ class SubscriptionsObservable: NSObject, ObservableObject {
Log.d(tag, "Fetching subscriptions") Log.d(tag, "Fetching subscriptions")
try controller.performFetch() try controller.performFetch()
} catch { } catch {
Log.w(tag, "Failed to fetch items: \(error)", error) Log.w(tag, "Failed to fetch subscriptions: \(error)", error)
} }
return controller return controller