Notifications: When multiple follow, open list of users instead of just one user

This commit is contained in:
Thomas Ricouard 2023-02-13 07:00:42 +01:00
parent 9867faa6de
commit 86aad4145a
4 changed files with 22 additions and 2 deletions

View file

@ -39,6 +39,8 @@ extension View {
AccountsListView(mode: .favoritedBy(statusId: id))
case let .rebloggedBy(id):
AccountsListView(mode: .rebloggedBy(statusId: id))
case let .accountsList(accounts):
AccountsListView(mode: .accountsList(accounts: accounts))
}
}
}

View file

@ -5,6 +5,7 @@ import SwiftUI
public enum AccountsListMode {
case following(accountId: String), followers(accountId: String)
case favoritedBy(statusId: String), rebloggedBy(statusId: String)
case accountsList(accounts: [Account])
var title: LocalizedStringKey {
switch self {
@ -16,6 +17,8 @@ public enum AccountsListMode {
return "account.favorited-by"
case .rebloggedBy:
return "account.boosted-by"
case .accountsList:
return ""
}
}
}
@ -67,6 +70,9 @@ class AccountsListViewModel: ObservableObject {
case let .favoritedBy(statusId):
(accounts, link) = try await client.getWithLink(endpoint: Statuses.favoritedBy(id: statusId,
maxId: nil))
case let .accountsList(accounts):
self.accounts = accounts
link = nil
}
nextPageId = link?.maxId
relationships = try await client.get(endpoint:
@ -96,6 +102,9 @@ class AccountsListViewModel: ObservableObject {
case let .favoritedBy(statusId):
(newAccounts, link) = try await client.getWithLink(endpoint: Statuses.favoritedBy(id: statusId,
maxId: nextPageId))
case .accountsList:
newAccounts = []
link = nil
}
accounts.append(contentsOf: newAccounts)
let newRelationships: [Relationship] =

View file

@ -17,6 +17,7 @@ public enum RouterDestinations: Hashable {
case following(id: String)
case favoritedBy(id: String)
case rebloggedBy(id: String)
case accountsList(accounts: [Account])
}
public enum SheetDestinations: Identifiable {

View file

@ -119,7 +119,11 @@ struct NotificationRowView: View {
}
.contentShape(Rectangle())
.onTapGesture {
routerPath.navigate(to: .accountDetailWithAccount(account: notification.accounts[0]))
if notification.accounts.count == 1 {
routerPath.navigate(to: .accountDetailWithAccount(account: notification.accounts[0]))
} else {
routerPath.navigate(to: .accountsList(accounts: notification.accounts))
}
}
}
@ -155,7 +159,11 @@ struct NotificationRowView: View {
}
.contentShape(Rectangle())
.onTapGesture {
routerPath.navigate(to: .accountDetailWithAccount(account: notification.accounts[0]))
if notification.accounts.count == 1 {
routerPath.navigate(to: .accountDetailWithAccount(account: notification.accounts[0]))
} else {
routerPath.navigate(to: .accountsList(accounts: notification.accounts))
}
}
}
}