2
2
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:
shannon 2025-01-22 15:14:58 -05:00
parent 76283cfa01
commit e91d6e3bc5
3 changed files with 26 additions and 1 deletions

View File

@ -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)
}
}
}
}

View File

@ -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 {

View File

@ -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 {