mirror of
https://github.com/mastodon/mastodon-ios
synced 2025-04-11 22:58:02 +02:00
Update notification view after approving or rejecting a follow request
Fixes #1342 [BUG] Follow requests no longer working
This commit is contained in:
parent
76283cfa01
commit
e91d6e3bc5
@ -120,6 +120,9 @@ extension NotificationTableViewCellDelegate where Self: DataSourceProvider & Aut
|
||||
notificationView: notificationView,
|
||||
query: .accept
|
||||
)
|
||||
if let self = self as? NotificationTimelineViewController {
|
||||
self.didActOnFollowRequest(notification, approved: true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -136,7 +139,7 @@ extension NotificationTableViewCellDelegate where Self: DataSourceProvider & Aut
|
||||
return
|
||||
}
|
||||
guard case let .notification(notification) = item else {
|
||||
assertionFailure("only works for status data provider")
|
||||
assertionFailure("only works for notification")
|
||||
return
|
||||
}
|
||||
|
||||
@ -146,6 +149,9 @@ extension NotificationTableViewCellDelegate where Self: DataSourceProvider & Aut
|
||||
notificationView: notificationView,
|
||||
query: .reject
|
||||
)
|
||||
if let self = self as? NotificationTimelineViewController {
|
||||
self.didActOnFollowRequest(notification, approved: false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -47,6 +47,10 @@ class NotificationTimelineViewController: UIViewController, MediaPreviewableView
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") }
|
||||
|
||||
func didActOnFollowRequest(_ notification: MastodonNotification, approved: Bool) {
|
||||
viewModel.didActOnFollowRequest(notification, approved: approved)
|
||||
}
|
||||
}
|
||||
|
||||
extension NotificationTimelineViewController {
|
||||
|
@ -70,6 +70,21 @@ final class NotificationTimelineViewModel {
|
||||
await self.loadLatest()
|
||||
}
|
||||
}
|
||||
|
||||
func didActOnFollowRequest(_ notification: MastodonNotification, approved: Bool) {
|
||||
defer {
|
||||
Task {
|
||||
await loadLatest()
|
||||
}
|
||||
}
|
||||
guard var currentSnapshot = diffableDataSource?.snapshot() else { return }
|
||||
let identifier = NotificationListItem.notification(.notification(id: notification.id))
|
||||
if currentSnapshot.itemIdentifiers.contains(identifier) {
|
||||
if !approved {
|
||||
currentSnapshot.deleteItems([identifier])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension NotificationTimelineViewModel {
|
||||
|
Loading…
x
Reference in New Issue
Block a user