status: add settings for disabling statuses in the UI

Suggested-by: Tanel
Changelog-Added: Add settings for disabling user statuses
This commit is contained in:
William Casarin
2023-08-23 16:42:38 -07:00
parent db59f74970
commit d02fc9142d
7 changed files with 32 additions and 9 deletions

View File

@@ -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)
}
}

View File

@@ -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

View File

@@ -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

View File

@@ -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)
}
}
}

View File

@@ -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)
}
}

View File

@@ -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)

View File

@@ -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)
}
}