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