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,7 +135,9 @@ class ActionNotificationGroupCollectionViewCell: UICollectionViewListCell {
|
||||||
|
|
||||||
updateTimestamp()
|
updateTimestamp()
|
||||||
|
|
||||||
let people = group.notifications.compactMap {
|
let people = group.notifications
|
||||||
|
.uniques(by: \.account.id)
|
||||||
|
.compactMap {
|
||||||
mastodonController.persistentContainer.account(for: $0.account.id)
|
mastodonController.persistentContainer.account(for: $0.account.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -109,7 +109,11 @@ class FollowNotificationGroupCollectionViewCell: UICollectionViewListCell {
|
||||||
}
|
}
|
||||||
self.group = group
|
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 {
|
actionLabel.setEmojis(pairs: people.map {
|
||||||
($0.displayOrUserName, $0.emojis)
|
($0.displayOrUserName, $0.emojis)
|
||||||
|
|
|
@ -627,11 +627,11 @@ extension NotificationsCollectionViewController: UICollectionViewDelegate {
|
||||||
case .favourite, .reblog:
|
case .favourite, .reblog:
|
||||||
let type = group.kind == .favourite ? StatusActionAccountListViewController.ActionType.favorite : .reblog
|
let type = group.kind == .favourite ? StatusActionAccountListViewController.ActionType.favorite : .reblog
|
||||||
let statusID = group.notifications.first!.status!.id
|
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)
|
let vc = StatusActionAccountListViewController(actionType: type, statusID: statusID, statusState: .unknown, accountIDs: accountIDs, mastodonController: mastodonController)
|
||||||
show(vc)
|
show(vc)
|
||||||
case .follow:
|
case .follow:
|
||||||
let accountIDs = group.notifications.map(\.account.id)
|
let accountIDs = group.notifications.map(\.account.id).uniques()
|
||||||
switch accountIDs.count {
|
switch accountIDs.count {
|
||||||
case 0:
|
case 0:
|
||||||
collectionView.deselectItem(at: indexPath, animated: true)
|
collectionView.deselectItem(at: indexPath, animated: true)
|
||||||
|
@ -670,11 +670,11 @@ extension NotificationsCollectionViewController: UICollectionViewDelegate {
|
||||||
return UIContextMenuConfiguration(previewProvider: {
|
return UIContextMenuConfiguration(previewProvider: {
|
||||||
let type = group.kind == .favourite ? StatusActionAccountListViewController.ActionType.favorite : .reblog
|
let type = group.kind == .favourite ? StatusActionAccountListViewController.ActionType.favorite : .reblog
|
||||||
let statusID = group.notifications.first!.status!.id
|
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)
|
return StatusActionAccountListViewController(actionType: type, statusID: statusID, statusState: .unknown, accountIDs: accountIDs, mastodonController: self.mastodonController)
|
||||||
})
|
})
|
||||||
case .follow:
|
case .follow:
|
||||||
let accountIDs = group.notifications.map(\.account.id)
|
let accountIDs = group.notifications.map(\.account.id).uniques()
|
||||||
return UIContextMenuConfiguration {
|
return UIContextMenuConfiguration {
|
||||||
if accountIDs.count == 1 {
|
if accountIDs.count == 1 {
|
||||||
return ProfileViewController(accountID: accountIDs.first!, mastodonController: self.mastodonController)
|
return ProfileViewController(accountID: accountIDs.first!, mastodonController: self.mastodonController)
|
||||||
|
|
Loading…
Reference in New Issue