damus

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

commit 015e0651a4b6937cc8da9f403e7b9a8084f58707
parent caa03e336f0f1db21b1ffbd994865b9c688397df
Author: William Casarin <jb55@jb55.com>
Date:   Sun, 18 Dec 2022 16:23:53 -0800

img: only show images if it is a post from your friend

Changelog-Changed: Only show inline images from your friends

Diffstat:
Mdamus/Views/ChatView.swift | 2+-
Mdamus/Views/DMView.swift | 2+-
Mdamus/Views/EventView.swift | 10+++++++++-
3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/damus/Views/ChatView.swift b/damus/Views/ChatView.swift @@ -106,7 +106,7 @@ struct ChatView: View { } } - NoteContentView(privkey: damus_state.keypair.privkey, event: event, profiles: damus_state.profiles, show_images: true, artifacts: .just_content(event.content)) + NoteContentView(privkey: damus_state.keypair.privkey, event: event, profiles: damus_state.profiles, show_images: should_show_images(contacts: damus_state.contacts, ev: event), artifacts: .just_content(event.content)) if is_active || next_ev == nil || next_ev!.pubkey != event.pubkey { let bar = make_actionbar_model(ev: event, damus: damus_state) diff --git a/damus/Views/DMView.swift b/damus/Views/DMView.swift @@ -21,7 +21,7 @@ struct DMView: View { Spacer() } - NoteContentView(privkey: damus_state.keypair.privkey, event: event, profiles: damus_state.profiles, show_images: true, artifacts: .just_content(event.get_content(damus_state.keypair.privkey))) + NoteContentView(privkey: damus_state.keypair.privkey, event: event, profiles: damus_state.profiles, show_images: should_show_images(contacts: damus_state.contacts, ev: event), artifacts: .just_content(event.get_content(damus_state.keypair.privkey))) .foregroundColor(is_ours ? Color.white : Color.primary) .padding(10) .background(is_ours ? Color.accentColor : Color.secondary.opacity(0.15)) diff --git a/damus/Views/EventView.swift b/damus/Views/EventView.swift @@ -131,7 +131,7 @@ struct EventView: View { .frame(maxWidth: .infinity, alignment: .leading) } - NoteContentView(privkey: damus.keypair.privkey, event: event, profiles: damus.profiles, show_images: true, artifacts: .just_content(content)) + NoteContentView(privkey: damus.keypair.privkey, event: event, profiles: damus.profiles, show_images: should_show_images(contacts: damus.contacts, ev: event), artifacts: .just_content(content)) .frame(maxWidth: .infinity, alignment: .leading) if has_action_bar { @@ -153,6 +153,14 @@ struct EventView: View { } } +// blame the porn bots for this code +func should_show_images(contacts: Contacts, ev: NostrEvent) -> Bool { + if contacts.is_friend(ev.pubkey) { + return true + } + return false +} + func event_validity_color(_ validation: ValidationResult) -> some View { Group { switch validation {