damus

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

commit 57d48a0395eb5b288ecc8ff9e09ae52cf4402105
parent 4f96c88b9b28c5738e28b1cb89a87f8f842ce7b8
Author: William Casarin <jb55@jb55.com>
Date:   Wed, 15 Mar 2023 16:40:17 -0600

Add option to always show images (never blur)

Changelog-Added: Add option to always show images (never blur)

Diffstat:
Mdamus/Models/UserSettingsStore.swift | 7+++++++
Mdamus/Views/ChatView.swift | 2+-
Mdamus/Views/ConfigView.swift | 2++
Mdamus/Views/DMView.swift | 2+-
Mdamus/Views/EventView.swift | 6+++++-
Mdamus/Views/Events/EventBody.swift | 2+-
6 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/damus/Models/UserSettingsStore.swift b/damus/Models/UserSettingsStore.swift @@ -100,6 +100,12 @@ class UserSettingsStore: ObservableObject { UserDefaults.standard.set(left_handed, forKey: "left_handed") } } + + @Published var always_show_images: Bool { + didSet { + UserDefaults.standard.set(always_show_images, forKey: "always_show_images") + } + } @Published var zap_vibration: Bool { didSet { @@ -182,6 +188,7 @@ class UserSettingsStore: ObservableObject { let pubkey = "" self.default_wallet = get_default_wallet(pubkey) show_wallet_selector = should_show_wallet_selector(pubkey) + always_show_images = UserDefaults.standard.object(forKey: "always_show_images") as? Bool ?? false left_handed = UserDefaults.standard.object(forKey: "left_handed") as? Bool ?? false zap_vibration = UserDefaults.standard.object(forKey: "zap_vibration") as? Bool ?? false diff --git a/damus/Views/ChatView.swift b/damus/Views/ChatView.swift @@ -108,7 +108,7 @@ struct ChatView: View { } } - let show_images = should_show_images(contacts: damus_state.contacts, ev: event, our_pubkey: damus_state.pubkey) + let show_images = should_show_images(settings: damus_state.settings, contacts: damus_state.contacts, ev: event, our_pubkey: damus_state.pubkey) NoteContentView(damus_state: damus_state, event: event, show_images: show_images, diff --git a/damus/Views/ConfigView.swift b/damus/Views/ConfigView.swift @@ -207,6 +207,8 @@ struct ConfigView: View { .onChange(of: settings.disable_animation) { _ in clear_kingfisher_cache() } + Toggle(NSLocalizedString("Always show images", comment: "Setting to always show and never blur images"), isOn: $settings.always_show_images) + .toggleStyle(.switch) Button(NSLocalizedString("Clear Cache", comment: "Button to clear image cache.")) { clear_kingfisher_cache() diff --git a/damus/Views/DMView.swift b/damus/Views/DMView.swift @@ -21,7 +21,7 @@ struct DMView: View { Spacer(minLength: UIScreen.main.bounds.width * 0.2) } - let should_show_img = should_show_images(contacts: damus_state.contacts, ev: event, our_pubkey: damus_state.pubkey) + let should_show_img = should_show_images(settings: damus_state.settings, contacts: damus_state.contacts, ev: event, our_pubkey: damus_state.pubkey) NoteContentView(damus_state: damus_state, event: event, show_images: should_show_img, size: .normal, artifacts: .just_content(event.get_content(damus_state.keypair.privkey)), truncate: false) .padding(10) diff --git a/damus/Views/EventView.swift b/damus/Views/EventView.swift @@ -89,7 +89,11 @@ struct EventView: View { } // blame the porn bots for this code -func should_show_images(contacts: Contacts, ev: NostrEvent, our_pubkey: String, booster_pubkey: String? = nil) -> Bool { +func should_show_images(settings: UserSettingsStore, contacts: Contacts, ev: NostrEvent, our_pubkey: String, booster_pubkey: String? = nil) -> Bool { + if settings.always_show_images { + return true + } + if ev.pubkey == our_pubkey { return true } diff --git a/damus/Views/Events/EventBody.swift b/damus/Views/Events/EventBody.swift @@ -17,7 +17,7 @@ struct EventBody: View { self.damus_state = damus_state self.event = event self.size = size - self.should_show_img = should_show_img ?? should_show_images(contacts: damus_state.contacts, ev: event, our_pubkey: damus_state.pubkey) + self.should_show_img = should_show_img ?? should_show_images(settings: damus_state.settings, contacts: damus_state.contacts, ev: event, our_pubkey: damus_state.pubkey) } var content: String {