View muted and blocked users

This commit is contained in:
Justin Mazzocchi 2020-12-01 15:23:47 -08:00
parent 637b926db0
commit 32541e68e1
No known key found for this signature in database
GPG key ID: E223E6937AAFB01C
5 changed files with 38 additions and 4 deletions

View file

@ -50,6 +50,7 @@
"pending.pending-confirmation" = "Your account is pending confirmation";
"preferences" = "Preferences";
"preferences.app" = "App Preferences";
"preferences.blocked-users" = "Blocked Users";
"preferences.media" = "Media";
"preferences.media.use-system-reduce-motion" = "Use system reduce motion setting";
"preferences.media.avatars" = "Avatars";
@ -83,6 +84,7 @@
"preferences.notification-types.reblog" = "Reblog";
"preferences.notification-types.mention" = "Mention";
"preferences.notification-types.poll" = "Poll";
"preferences.muted-users" = "Muted Users";
"preferences.startup-and-syncing" = "Startup and Syncing";
"preferences.startup-and-syncing.home-timeline" = "Home timeline";
"preferences.startup-and-syncing.notifications-tab" = "Notifications tab";

View file

@ -7,6 +7,8 @@ import Mastodon
public enum AccountsEndpoint {
case rebloggedBy(id: Status.Id)
case favouritedBy(id: Status.Id)
case mutes
case blocks
}
extension AccountsEndpoint: Endpoint {
@ -16,6 +18,8 @@ extension AccountsEndpoint: Endpoint {
switch self {
case .rebloggedBy, .favouritedBy:
return defaultContext + ["statuses"]
case .mutes, .blocks:
return defaultContext
}
}
@ -25,13 +29,14 @@ extension AccountsEndpoint: Endpoint {
return [id, "reblogged_by"]
case let .favouritedBy(id):
return [id, "favourited_by"]
case .mutes:
return ["mutes"]
case .blocks:
return ["blocks"]
}
}
public var method: HTTPMethod {
switch self {
case .rebloggedBy, .favouritedBy:
return .get
}
.get
}
}

View file

@ -210,6 +210,13 @@ public extension IdentityService {
TimelineService(timeline: timeline, mastodonAPIClient: mastodonAPIClient, contentDatabase: contentDatabase)
}
func service(accountList: AccountsEndpoint) -> AccountListService {
AccountListService(
endpoint: accountList,
mastodonAPIClient: mastodonAPIClient,
contentDatabase: contentDatabase)
}
func notificationsService() -> NotificationsService {
NotificationsService(mastodonAPIClient: mastodonAPIClient, contentDatabase: contentDatabase)
}

View file

@ -16,3 +16,17 @@ public final class PreferencesViewModel: ObservableObject {
shouldShowNotificationTypePreferences = identification.identity.lastRegisteredDeviceToken != nil
}
}
public extension PreferencesViewModel {
func mutedUsersViewModel() -> CollectionViewModel {
CollectionItemsViewModel(
collectionService: identification.service.service(accountList: .mutes),
identification: identification)
}
func blockedUsersViewModel() -> CollectionViewModel {
CollectionItemsViewModel(
collectionService: identification.service.service(accountList: .blocks),
identification: identification)
}
}

View file

@ -21,6 +21,12 @@ struct PreferencesView: View {
destination: NotificationTypesPreferencesView(
viewModel: .init(identification: identification)))
}
NavigationLink("preferences.muted-users",
destination: TableView(viewModel: viewModel.mutedUsersViewModel())
.navigationTitle(Text("preferences.muted-users")))
NavigationLink("preferences.blocked-users",
destination: TableView(viewModel: viewModel.blockedUsersViewModel())
.navigationTitle(Text("preferences.blocked-users")))
}
Section(header: Text("preferences.app")) {
NavigationLink("preferences.media",