Add muted and blocked accounts list

This commit is contained in:
Thomas Ricouard 2024-05-02 08:43:58 +02:00
parent 6a7df1065d
commit abcd4cc321
8 changed files with 408 additions and 121 deletions

View file

@ -70,6 +70,10 @@ extension View {
NotificationsListView(lockedType: nil ,
lockedAccountId: accountId,
scrollToTopSignal: .constant(0))
case .blockedAccounts:
AccountsListView(mode: .blocked)
case .mutedAccounts:
AccountsListView(mode: .muted)
}
}
}

View file

@ -1,126 +1,6 @@
{
"sourceLanguage" : "en",
"strings" : {
"action.cancel" : {
"comment" : "MARK: Common strings",
"extractionState" : "stale",
"localizations" : {
"be" : {
"stringUnit" : {
"state" : "translated",
"value" : "Скасаваць"
}
},
"ca" : {
"stringUnit" : {
"state" : "translated",
"value" : "Cancel·la"
}
},
"de" : {
"stringUnit" : {
"state" : "translated",
"value" : "Abbrechen"
}
},
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Cancel"
}
},
"en-GB" : {
"stringUnit" : {
"state" : "translated",
"value" : "Cancel"
}
},
"es" : {
"stringUnit" : {
"state" : "translated",
"value" : "Cancelar"
}
},
"eu" : {
"stringUnit" : {
"state" : "translated",
"value" : "Utzi"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
"value" : "Annuler"
}
},
"it" : {
"stringUnit" : {
"state" : "translated",
"value" : "Annulla"
}
},
"ja" : {
"stringUnit" : {
"state" : "translated",
"value" : "キャンセル"
}
},
"ko" : {
"stringUnit" : {
"state" : "translated",
"value" : "취소"
}
},
"nb" : {
"stringUnit" : {
"state" : "translated",
"value" : "Avbryt"
}
},
"nl" : {
"stringUnit" : {
"state" : "translated",
"value" : "Annuleer"
}
},
"pl" : {
"stringUnit" : {
"state" : "translated",
"value" : "Anuluj"
}
},
"pt-BR" : {
"stringUnit" : {
"state" : "translated",
"value" : "Cancelar"
}
},
"tr" : {
"stringUnit" : {
"state" : "translated",
"value" : "İptal Et"
}
},
"uk" : {
"stringUnit" : {
"state" : "translated",
"value" : "Відміна"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "取消"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "取消"
}
}
}
},
"" : {
"localizations" : {
"be" : {
@ -11587,6 +11467,125 @@
}
}
},
"account.blocked" : {
"extractionState" : "manual",
"localizations" : {
"be" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Blocked accounts"
}
},
"ca" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Blocked accounts"
}
},
"de" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Blocked accounts"
}
},
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Blocked accounts"
}
},
"en-GB" : {
"stringUnit" : {
"state" : "translated",
"value" : "Blocked accounts"
}
},
"es" : {
"stringUnit" : {
"state" : "needs_review",
"value" : ""
}
},
"eu" : {
"stringUnit" : {
"state" : "translated",
"value" : "Blocked accounts"
}
},
"fr" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Blocked accounts"
}
},
"it" : {
"stringUnit" : {
"state" : "translated",
"value" : "Blocked accounts"
}
},
"ja" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Blocked accounts"
}
},
"ko" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Blocked accounts"
}
},
"nb" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Blocked accounts"
}
},
"nl" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Blocked accounts"
}
},
"pl" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Blocked accounts"
}
},
"pt-BR" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Blocked accounts"
}
},
"tr" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Blocked accounts"
}
},
"uk" : {
"stringUnit" : {
"state" : "translated",
"value" : "Blocked accounts"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Blocked accounts"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Blocked accounts"
}
}
}
},
"account.boosted-by" : {
"extractionState" : "manual",
"localizations" : {
@ -17312,6 +17311,125 @@
}
}
},
"account.muted" : {
"extractionState" : "manual",
"localizations" : {
"be" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Muted accounts"
}
},
"ca" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Muted accounts"
}
},
"de" : {
"stringUnit" : {
"state" : "needs_review",
"value" : ""
}
},
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Muted accounts"
}
},
"en-GB" : {
"stringUnit" : {
"state" : "translated",
"value" : "Muted accounts"
}
},
"es" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Muted accounts"
}
},
"eu" : {
"stringUnit" : {
"state" : "translated",
"value" : "Muted accounts"
}
},
"fr" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Muted accounts"
}
},
"it" : {
"stringUnit" : {
"state" : "needs_review",
"value" : ""
}
},
"ja" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Muted accounts"
}
},
"ko" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Muted accounts"
}
},
"nb" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Muted accounts"
}
},
"nl" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Muted accounts"
}
},
"pl" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Muted accounts"
}
},
"pt-BR" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Muted accounts"
}
},
"tr" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Muted accounts"
}
},
"uk" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Muted accounts"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Muted accounts"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "Muted accounts"
}
}
}
},
"account.post.pinned" : {
"extractionState" : "manual",
"localizations" : {
@ -18264,6 +18382,126 @@
}
}
},
"action.cancel" : {
"comment" : "MARK: Common strings",
"extractionState" : "stale",
"localizations" : {
"be" : {
"stringUnit" : {
"state" : "translated",
"value" : "Скасаваць"
}
},
"ca" : {
"stringUnit" : {
"state" : "translated",
"value" : "Cancel·la"
}
},
"de" : {
"stringUnit" : {
"state" : "translated",
"value" : "Abbrechen"
}
},
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Cancel"
}
},
"en-GB" : {
"stringUnit" : {
"state" : "translated",
"value" : "Cancel"
}
},
"es" : {
"stringUnit" : {
"state" : "translated",
"value" : "Cancelar"
}
},
"eu" : {
"stringUnit" : {
"state" : "translated",
"value" : "Utzi"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
"value" : "Annuler"
}
},
"it" : {
"stringUnit" : {
"state" : "translated",
"value" : "Annulla"
}
},
"ja" : {
"stringUnit" : {
"state" : "translated",
"value" : "キャンセル"
}
},
"ko" : {
"stringUnit" : {
"state" : "translated",
"value" : "취소"
}
},
"nb" : {
"stringUnit" : {
"state" : "translated",
"value" : "Avbryt"
}
},
"nl" : {
"stringUnit" : {
"state" : "translated",
"value" : "Annuleer"
}
},
"pl" : {
"stringUnit" : {
"state" : "translated",
"value" : "Anuluj"
}
},
"pt-BR" : {
"stringUnit" : {
"state" : "translated",
"value" : "Cancelar"
}
},
"tr" : {
"stringUnit" : {
"state" : "translated",
"value" : "İptal Et"
}
},
"uk" : {
"stringUnit" : {
"state" : "translated",
"value" : "Відміна"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "取消"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "取消"
}
}
}
},
"action.delete" : {
"extractionState" : "manual",
"localizations" : {
@ -80231,4 +80469,4 @@
}
},
"version" : "1.0"
}
}

View file

@ -326,6 +326,21 @@ public struct AccountDetailView: View {
if let account = viewModel.account {
Divider()
Button {
routerPath.navigate(to: .blockedAccounts)
} label: {
Label("account.blocked", systemImage: "person.crop.circle.badge.xmark")
}
Button {
routerPath.navigate(to: .mutedAccounts)
} label: {
Label("account.muted", systemImage: "person.crop.circle.badge.moon")
}
Divider()
Button {
if let url = URL(string: "https://mastometrics.com/auth/login?username=\(account.acct)@\(client.server)&instance=\(client.server)&auto=true") {

View file

@ -52,6 +52,9 @@ public struct AccountsListView: View {
searchableList
} else {
standardList
.refreshable {
await viewModel.fetch()
}
}
}

View file

@ -8,6 +8,7 @@ public enum AccountsListMode {
case following(accountId: String), followers(accountId: String)
case favoritedBy(statusId: String), rebloggedBy(statusId: String)
case accountsList(accounts: [Account])
case blocked, muted
var title: LocalizedStringKey {
switch self {
@ -21,6 +22,10 @@ public enum AccountsListMode {
"account.boosted-by"
case .accountsList:
""
case .blocked:
"account.blocked"
case .muted:
"account.muted"
}
}
}
@ -84,6 +89,12 @@ public enum AccountsListMode {
case let .accountsList(accounts):
self.accounts = accounts
link = nil
case .blocked:
(accounts, link) = try await client.getWithLink(endpoint: Accounts.blockList)
case .muted:
(accounts, link) = try await client.getWithLink(endpoint: Accounts.muteList)
}
nextPageId = link?.maxId
relationships = try await client.get(endpoint:
@ -114,7 +125,14 @@ public enum AccountsListMode {
case .accountsList:
newAccounts = []
link = nil
case .blocked:
(newAccounts, link) = try await client.getWithLink(endpoint: Accounts.blockList)
case .muted:
(newAccounts, link) = try await client.getWithLink(endpoint: Accounts.muteList)
}
accounts.append(contentsOf: newAccounts)
let newRelationships: [Relationship] =
try await client.get(endpoint: Accounts.relationships(ids: newAccounts.map(\.id)))

View file

@ -25,6 +25,8 @@ public enum RouterDestination: Hashable {
case tagsList(tags: [Tag])
case notificationsRequests
case notificationForAccount(accountId: String)
case blockedAccounts
case mutedAccounts
}
public enum WindowDestinationEditor: Hashable, Codable {

View file

@ -39,6 +39,7 @@ public struct ListCreateView: View {
.scrollContentBackground(.hidden)
.background(theme.secondaryBackgroundColor)
.toolbar {
CancelToolbarItem()
ToolbarItem {
Button {
Task {

View file

@ -32,6 +32,8 @@ public enum Accounts: Endpoint {
case mute(id: String, json: MuteData)
case unmute(id: String)
case relationshipNote(id: String, json: RelationshipNoteData)
case blockList
case muteList
public func path() -> String {
switch self {
@ -81,6 +83,10 @@ public enum Accounts: Endpoint {
"accounts/\(id)/unmute"
case let .relationshipNote(id, _):
"accounts/\(id)/note"
case .blockList:
"blocks"
case .muteList:
"mutes"
}
}