damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit d02fc9142dcf07a5c329f8bea27dd9d91c55feb1
parent db59f7497005c9db0aa8ff25140e2baa60fdea98
Author: William Casarin <jb55@jb55.com>
Date:   Wed, 23 Aug 2023 16:42:38 -0700

status: add settings for disabling statuses in the UI

Suggested-by: Tanel
Changelog-Added: Add settings for disabling user statuses

Diffstat:
Mdamus/Components/Status/UserStatusView.swift | 9++++++---
Mdamus/Models/HomeModel.swift | 7++++++-
Mdamus/Models/UserSettingsStore.swift | 6++++++
Mdamus/Views/Events/EventProfile.swift | 3++-
Mdamus/Views/Events/EventShell.swift | 4++--
Mdamus/Views/Settings/AppearanceSettingsView.swift | 10+++++++++-
Mdamus/Views/SideMenuView.swift | 2+-
7 files changed, 32 insertions(+), 9 deletions(-)

diff --git a/damus/Components/Status/UserStatusView.swift b/damus/Components/Status/UserStatusView.swift @@ -12,16 +12,19 @@ import MediaPlayer struct UserStatusView: View { @ObservedObject var status: UserStatusModel + var show_general: Bool + var show_music: Bool + var body: some View { VStack(alignment: .leading, spacing: 2) { - if let general = status.general { + if show_general, let general = status.general { Text(verbatim: "\(general.content)") .lineLimit(1) .foregroundColor(.gray) .font(.callout.italic()) } - if let playing = status.music { + if show_music, let playing = status.music { Text(verbatim: "🎵\(playing.content)") .lineLimit(1) .foregroundColor(.gray) @@ -34,6 +37,6 @@ struct UserStatusView: View { struct UserStatusView_Previews: PreviewProvider { static var previews: some View { - UserStatusView(status: .init()) + UserStatusView(status: .init(), show_general: true, show_music: true) } } diff --git a/damus/Models/HomeModel.swift b/damus/Models/HomeModel.swift @@ -530,12 +530,17 @@ class HomeModel { func subscribe_to_home_filters(friends fs: [Pubkey]? = nil, relay_id: String? = nil) { // TODO: separate likes? var home_filter_kinds: [NostrKind] = [ - .text, .longform, .boost, .status + .text, .longform, .boost ] if !damus_state.settings.onlyzaps_mode { home_filter_kinds.append(.like) } + // only pull status data if we care for it + if damus_state.settings.show_music_statuses || damus_state.settings.show_general_statuses { + home_filter_kinds.append(.status) + } + let friends = fs ?? get_friends() var home_filter = NostrFilter(kinds: home_filter_kinds) // include our pubkey as well even if we're not technically a friend diff --git a/damus/Models/UserSettingsStore.swift b/damus/Models/UserSettingsStore.swift @@ -159,6 +159,12 @@ class UserSettingsStore: ObservableObject { @Setting(key: "auto_translate", default_value: true) var auto_translate: Bool + @Setting(key: "show_general_statuses", default_value: true) + var show_general_statuses: Bool + + @Setting(key: "show_music_statuses", default_value: true) + var show_music_statuses: Bool + @Setting(key: "show_only_preferred_languages", default_value: false) var show_only_preferred_languages: Bool diff --git a/damus/Views/Events/EventProfile.swift b/damus/Views/Events/EventProfile.swift @@ -46,7 +46,8 @@ struct EventProfile: View { VStack(alignment: .leading) { EventProfileName(pubkey: pubkey, profile: profile, damus: damus_state, size: size) - UserStatusView(status: damus_state.profiles.profile_data(pubkey).status) + + UserStatusView(status: damus_state.profiles.profile_data(pubkey).status, show_general: damus_state.settings.show_general_statuses, show_music: damus_state.settings.show_music_statuses) } } } diff --git a/damus/Views/Events/EventShell.swift b/damus/Views/Events/EventShell.swift @@ -68,7 +68,7 @@ struct EventShell<Content: View>: View { VStack(alignment: .leading) { EventTop(state: state, event: event, pubkey: pubkey, is_anon: is_anon) - UserStatusView(status: state.profiles.profile_data(pubkey).status) + UserStatusView(status: state.profiles.profile_data(pubkey).status, show_general: state.settings.show_general_statuses, show_music: state.settings.show_music_statuses) if !options.contains(.no_replying_to) { ReplyPart(events: state.events, event: event, privkey: state.keypair.privkey, profiles: state.profiles) @@ -97,7 +97,7 @@ struct EventShell<Content: View>: View { VStack(alignment: .leading, spacing: 2) { EventTop(state: state, event: event, pubkey: pubkey, is_anon: is_anon) - UserStatusView(status: state.profiles.profile_data(pubkey).status) + UserStatusView(status: state.profiles.profile_data(pubkey).status, show_general: state.settings.show_general_statuses, show_music: state.settings.show_music_statuses) ReplyPart(events: state.events, event: event, privkey: state.keypair.privkey, profiles: state.profiles) } } diff --git a/damus/Views/Settings/AppearanceSettingsView.swift b/damus/Views/Settings/AppearanceSettingsView.swift @@ -48,7 +48,15 @@ struct AppearanceSettingsView: View { Toggle(NSLocalizedString("Truncate notification mention text", comment: "Setting to truncate text in mention notifications"), isOn: $settings.truncate_mention_text) .toggleStyle(.switch) } - + + Section(header: Text("User Statuses")) { + Toggle(NSLocalizedString("Show general statuses", comment: "Settings toggle for enabling general user statuses"), isOn: $settings.show_general_statuses) + .toggleStyle(.switch) + + Toggle(NSLocalizedString("Show music statuses", comment: "Settings toggle for enabling now playing music statuses"), isOn: $settings.show_music_statuses) + .toggleStyle(.switch) + } + // MARK: - Accessibility Section(header: Text(NSLocalizedString("Accessibility", comment: "Section header for accessibility settings"))) { Toggle(NSLocalizedString("Left Handed", comment: "Moves the post button to the left side of the screen"), isOn: $settings.left_handed) diff --git a/damus/Views/SideMenuView.swift b/damus/Views/SideMenuView.swift @@ -112,7 +112,7 @@ struct SideMenuView: View { present_sheet(.user_status) } - UserStatusView(status: damus_state.profiles.profile_data(damus_state.pubkey).status) + UserStatusView(status: damus_state.profiles.profile_data(damus_state.pubkey).status, show_general: true, show_music: true) .dynamicTypeSize(.xSmall) } }