damus

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

commit e2812a9aa18811a95936b34c2f1cf9d58f61de5e
parent 679779ab3e7d7ca8d237bb7997e9f3153fa70dcd
Author: Swift <scoder1747@gmail.com>
Date:   Tue,  4 Apr 2023 12:39:48 -0400

Add option to only show notification from people you follow

Changelog-Added: Add option to only show notification from people you follow
Closes: #866

Diffstat:
Mdamus/Models/HomeModel.swift | 8+++++++-
Mdamus/Models/UserSettingsStore.swift | 7+++++++
Mdamus/Views/ConfigView.swift | 5+++++
3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/damus/Models/HomeModel.swift b/damus/Models/HomeModel.swift @@ -999,7 +999,13 @@ func process_local_notification(damus_state: DamusState, event ev: NostrEvent) { guard let type = ev.known_kind else { return } - + + if damus_state.settings.notification_only_from_following, + damus_state.contacts.follow_state(ev.pubkey) != .follows + { + return + } + if type == .text && damus_state.settings.mention_notification { for block in ev.blocks(damus_state.keypair.privkey) { if case .mention(let mention) = block, mention.ref.ref_id == damus_state.keypair.pubkey, diff --git a/damus/Models/UserSettingsStore.swift b/damus/Models/UserSettingsStore.swift @@ -158,6 +158,12 @@ class UserSettingsStore: ObservableObject { } } + @Published var notification_only_from_following: Bool { + didSet { + UserDefaults.standard.set(like_notification, forKey: "notification_only_from_following") + } + } + @Published var truncate_timeline_text: Bool { didSet { UserDefaults.standard.set(truncate_timeline_text, forKey: "truncate_timeline_text") @@ -262,6 +268,7 @@ class UserSettingsStore: ObservableObject { repost_notification = UserDefaults.standard.object(forKey: "repost_notification") as? Bool ?? true like_notification = UserDefaults.standard.object(forKey: "like_notification") as? Bool ?? true dm_notification = UserDefaults.standard.object(forKey: "dm_notification") as? Bool ?? true + notification_only_from_following = UserDefaults.standard.object(forKey: "notification_only_from_following") as? Bool ?? false truncate_timeline_text = UserDefaults.standard.object(forKey: "truncate_timeline_text") as? Bool ?? false disable_animation = should_disable_image_animation() auto_translate = UserDefaults.standard.object(forKey: "auto_translate") as? Bool ?? true diff --git a/damus/Views/ConfigView.swift b/damus/Views/ConfigView.swift @@ -407,6 +407,11 @@ struct NotificationView: View { Toggle(NSLocalizedString("DMs", comment: "Setting to enable DM Local Notification"), isOn: $settings.dm_notification) .toggleStyle(.switch) } + + Section(header: Text(NSLocalizedString("Notification Preference", comment: "Section header for Notification Preferences"))) { + Toggle(NSLocalizedString("Show only from users you follow", comment: "Setting to Show notifications only associated to users your follow"), isOn: $settings.notification_only_from_following) + .toggleStyle(.switch) + } } } }