forked from shadowfacts/Tusker
Fix crash when there are multiple follow notifications for the same account
Only reproducible on Pixelfed
This commit is contained in:
parent
e522e30ce5
commit
46b455c3d1
@ -135,9 +135,11 @@ class ActionNotificationGroupCollectionViewCell: UICollectionViewListCell {
|
||||
|
||||
updateTimestamp()
|
||||
|
||||
let people = group.notifications.compactMap {
|
||||
mastodonController.persistentContainer.account(for: $0.account.id)
|
||||
}
|
||||
let people = group.notifications
|
||||
.uniques(by: \.account.id)
|
||||
.compactMap {
|
||||
mastodonController.persistentContainer.account(for: $0.account.id)
|
||||
}
|
||||
|
||||
let visibleAvatars = Array(people.lazy.compactMap(\.avatar).prefix(10))
|
||||
for (index, avatarURL) in visibleAvatars.enumerated() {
|
||||
|
@ -109,7 +109,11 @@ class FollowNotificationGroupCollectionViewCell: UICollectionViewListCell {
|
||||
}
|
||||
self.group = group
|
||||
|
||||
let people = group.notifications.compactMap { mastodonController.persistentContainer.account(for: $0.account.id) }
|
||||
let people = group.notifications
|
||||
.uniques(by: \.account.id)
|
||||
.compactMap {
|
||||
mastodonController.persistentContainer.account(for: $0.account.id)
|
||||
}
|
||||
|
||||
actionLabel.setEmojis(pairs: people.map {
|
||||
($0.displayOrUserName, $0.emojis)
|
||||
|
@ -627,11 +627,11 @@ extension NotificationsCollectionViewController: UICollectionViewDelegate {
|
||||
case .favourite, .reblog:
|
||||
let type = group.kind == .favourite ? StatusActionAccountListViewController.ActionType.favorite : .reblog
|
||||
let statusID = group.notifications.first!.status!.id
|
||||
let accountIDs = group.notifications.map(\.account.id)
|
||||
let accountIDs = group.notifications.map(\.account.id).uniques()
|
||||
let vc = StatusActionAccountListViewController(actionType: type, statusID: statusID, statusState: .unknown, accountIDs: accountIDs, mastodonController: mastodonController)
|
||||
show(vc)
|
||||
case .follow:
|
||||
let accountIDs = group.notifications.map(\.account.id)
|
||||
let accountIDs = group.notifications.map(\.account.id).uniques()
|
||||
switch accountIDs.count {
|
||||
case 0:
|
||||
collectionView.deselectItem(at: indexPath, animated: true)
|
||||
@ -670,11 +670,11 @@ extension NotificationsCollectionViewController: UICollectionViewDelegate {
|
||||
return UIContextMenuConfiguration(previewProvider: {
|
||||
let type = group.kind == .favourite ? StatusActionAccountListViewController.ActionType.favorite : .reblog
|
||||
let statusID = group.notifications.first!.status!.id
|
||||
let accountIDs = group.notifications.map(\.account.id)
|
||||
let accountIDs = group.notifications.map(\.account.id).uniques()
|
||||
return StatusActionAccountListViewController(actionType: type, statusID: statusID, statusState: .unknown, accountIDs: accountIDs, mastodonController: self.mastodonController)
|
||||
})
|
||||
case .follow:
|
||||
let accountIDs = group.notifications.map(\.account.id)
|
||||
let accountIDs = group.notifications.map(\.account.id).uniques()
|
||||
return UIContextMenuConfiguration {
|
||||
if accountIDs.count == 1 {
|
||||
return ProfileViewController(accountID: accountIDs.first!, mastodonController: self.mastodonController)
|
||||
|
Loading…
x
Reference in New Issue
Block a user