chore: add navigation to ThreadScene

This commit is contained in:
sunxiaojian 2021-04-18 22:00:19 +08:00
parent 780025a3ce
commit 462fafe706
2 changed files with 20 additions and 19 deletions

View File

@ -117,9 +117,9 @@ extension NotificationViewController {
if sender.selectedSegmentIndex == 0 {
viewModel.notificationPredicate.value = MastodonNotification.predicate(domain: domain, userID: userID)
} else {
viewModel.notificationPredicate.value = MastodonNotification.predicate(domain: domain,userID: userID, typeRaw: Mastodon.Entity.Notification.NotificationType.mention.rawValue)
viewModel.notificationPredicate.value = MastodonNotification.predicate(domain: domain, userID: userID, typeRaw: Mastodon.Entity.Notification.NotificationType.mention.rawValue)
}
viewModel.selectedIndex.value = NotificationViewModel.NotificationSegment.init(rawValue: sender.selectedSegmentIndex)!
viewModel.selectedIndex.value = NotificationViewModel.NotificationSegment(rawValue: sender.selectedSegmentIndex)!
}
@objc private func refreshControlValueChanged(_ sender: UIRefreshControl) {
@ -134,18 +134,18 @@ extension NotificationViewController {
extension NotificationViewController: UITableViewDelegate {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
guard let diffableDataSource = viewModel.diffableDataSource else { return }
guard let item = diffableDataSource.itemIdentifier(for: indexPath) else { return }
switch item {
case .notification(let objectID):
let notification = context.managedObjectContext.object(with: objectID) as! MastodonNotification
if notification.status != nil {
// TODO: goto status detail vc
if let status = notification.status {
let viewModel = ThreadViewModel(context: context, optionalStatus: status)
coordinator.present(scene: .thread(viewModel: viewModel), from: self, transition: .show)
} else {
let viewModel = ProfileViewModel(context: context, optionalMastodonUser: notification.account)
DispatchQueue.main.async {
self.coordinator.present(scene: .profile(viewModel: viewModel), from: self, transition: .show)
}
coordinator.present(scene: .profile(viewModel: viewModel), from: self, transition: .show)
}
default:
break

View File

@ -76,6 +76,7 @@ extension NotificationViewModel: NSFetchedResultsControllerDelegate {
guard let difference = self.calculateReloadSnapshotDifference(navigationBar: navigationBar, tableView: tableView, oldSnapshot: oldSnapshot, newSnapshot: newSnapshot) else {
diffableDataSource.apply(newSnapshot, animatingDifferences: false)
self.isFetchingLatestNotification.value = false
tableView.reloadData()
return
}