forked from zelo72/mastodon-ios
chore: add navigation to ThreadScene
This commit is contained in:
parent
780025a3ce
commit
462fafe706
|
@ -119,7 +119,7 @@ extension NotificationViewController {
|
||||||
} else {
|
} 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) {
|
@objc private func refreshControlValueChanged(_ sender: UIRefreshControl) {
|
||||||
|
@ -134,18 +134,18 @@ extension NotificationViewController {
|
||||||
|
|
||||||
extension NotificationViewController: UITableViewDelegate {
|
extension NotificationViewController: UITableViewDelegate {
|
||||||
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
||||||
|
tableView.deselectRow(at: indexPath, animated: true)
|
||||||
guard let diffableDataSource = viewModel.diffableDataSource else { return }
|
guard let diffableDataSource = viewModel.diffableDataSource else { return }
|
||||||
guard let item = diffableDataSource.itemIdentifier(for: indexPath) else { return }
|
guard let item = diffableDataSource.itemIdentifier(for: indexPath) else { return }
|
||||||
switch item {
|
switch item {
|
||||||
case .notification(let objectID):
|
case .notification(let objectID):
|
||||||
let notification = context.managedObjectContext.object(with: objectID) as! MastodonNotification
|
let notification = context.managedObjectContext.object(with: objectID) as! MastodonNotification
|
||||||
if notification.status != nil {
|
if let status = notification.status {
|
||||||
// TODO: goto status detail vc
|
let viewModel = ThreadViewModel(context: context, optionalStatus: status)
|
||||||
|
coordinator.present(scene: .thread(viewModel: viewModel), from: self, transition: .show)
|
||||||
} else {
|
} else {
|
||||||
let viewModel = ProfileViewModel(context: context, optionalMastodonUser: notification.account)
|
let viewModel = ProfileViewModel(context: context, optionalMastodonUser: notification.account)
|
||||||
DispatchQueue.main.async {
|
coordinator.present(scene: .profile(viewModel: viewModel), from: self, transition: .show)
|
||||||
self.coordinator.present(scene: .profile(viewModel: viewModel), from: self, transition: .show)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
|
|
|
@ -76,6 +76,7 @@ extension NotificationViewModel: NSFetchedResultsControllerDelegate {
|
||||||
guard let difference = self.calculateReloadSnapshotDifference(navigationBar: navigationBar, tableView: tableView, oldSnapshot: oldSnapshot, newSnapshot: newSnapshot) else {
|
guard let difference = self.calculateReloadSnapshotDifference(navigationBar: navigationBar, tableView: tableView, oldSnapshot: oldSnapshot, newSnapshot: newSnapshot) else {
|
||||||
diffableDataSource.apply(newSnapshot, animatingDifferences: false)
|
diffableDataSource.apply(newSnapshot, animatingDifferences: false)
|
||||||
self.isFetchingLatestNotification.value = false
|
self.isFetchingLatestNotification.value = false
|
||||||
|
tableView.reloadData()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue