From 11180ae62d486d4433afe40e9e8fcc4bfc06bc2f Mon Sep 17 00:00:00 2001 From: CMK Date: Fri, 2 Jul 2021 14:01:53 +0800 Subject: [PATCH] fix: notification not trigger update issue --- Mastodon/Diffiable/Section/NotificationSection.swift | 4 +++- .../Scene/Notification/NotificationViewController.swift | 7 +++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Mastodon/Diffiable/Section/NotificationSection.swift b/Mastodon/Diffiable/Section/NotificationSection.swift index fc88fddec..267f47b7d 100644 --- a/Mastodon/Diffiable/Section/NotificationSection.swift +++ b/Mastodon/Diffiable/Section/NotificationSection.swift @@ -30,7 +30,9 @@ extension NotificationSection { guard let dependency = dependency else { return nil } switch notificationItem { case .notification(let objectID, let attribute): - let notification = managedObjectContext.object(with: objectID) as! MastodonNotification + guard let notification = try? managedObjectContext.existingObject(with: objectID) as? MastodonNotification else { + return UITableViewCell() + } guard let type = Mastodon.Entity.Notification.NotificationType(rawValue: notification.typeRaw) else { // filter out invalid type using predicate assertionFailure() diff --git a/Mastodon/Scene/Notification/NotificationViewController.swift b/Mastodon/Scene/Notification/NotificationViewController.swift index 1a1672bf8..8ac57a9f1 100644 --- a/Mastodon/Scene/Notification/NotificationViewController.swift +++ b/Mastodon/Scene/Notification/NotificationViewController.swift @@ -143,10 +143,9 @@ extension NotificationViewController { tableView.deselectRow(with: transitionCoordinator, animated: animated) - // fetch latest if has unread push notification - if context.notificationService.hasUnreadPushNotification.value { - viewModel.loadLatestStateMachine.enter(NotificationViewModel.LoadLatestState.Loading.self) - } + // fetch latest notification when will appear + viewModel.loadLatestStateMachine.enter(NotificationViewModel.LoadLatestState.Loading.self) + // needs trigger manually after onboarding dismiss setNeedsStatusBarAppearanceUpdate()