fix: notification not trigger update issue

This commit is contained in:
CMK 2021-07-02 14:01:53 +08:00
parent 6c6ab615c7
commit 11180ae62d
2 changed files with 6 additions and 5 deletions

View File

@ -30,7 +30,9 @@ extension NotificationSection {
guard let dependency = dependency else { return nil } guard let dependency = dependency else { return nil }
switch notificationItem { switch notificationItem {
case .notification(let objectID, let attribute): 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 { guard let type = Mastodon.Entity.Notification.NotificationType(rawValue: notification.typeRaw) else {
// filter out invalid type using predicate // filter out invalid type using predicate
assertionFailure() assertionFailure()

View File

@ -143,10 +143,9 @@ extension NotificationViewController {
tableView.deselectRow(with: transitionCoordinator, animated: animated) tableView.deselectRow(with: transitionCoordinator, animated: animated)
// fetch latest if has unread push notification // fetch latest notification when will appear
if context.notificationService.hasUnreadPushNotification.value {
viewModel.loadLatestStateMachine.enter(NotificationViewModel.LoadLatestState.Loading.self) viewModel.loadLatestStateMachine.enter(NotificationViewModel.LoadLatestState.Loading.self)
}
// needs trigger manually after onboarding dismiss // needs trigger manually after onboarding dismiss
setNeedsStatusBarAppearanceUpdate() setNeedsStatusBarAppearanceUpdate()