From 40be9885c5f00e95a6b98eb33d179c9ccf34b6ee Mon Sep 17 00:00:00 2001 From: radixrat Date: Thu, 2 Feb 2023 13:53:57 -0800 Subject: [PATCH 1/3] add remote loading image setting --- damus/ContentView.swift | 2 +- damus/Views/ChatView.swift | 4 +-- damus/Views/ConfigView.swift | 38 ++++++++++++++++++++++-- damus/Views/DMChatView.swift | 2 +- damus/Views/EventView.swift | 2 +- damus/Views/ProfilePicView.swift | 18 ++++++++--- damus/Views/ProfilePictureSelector.swift | 2 +- 7 files changed, 56 insertions(+), 12 deletions(-) diff --git a/damus/ContentView.swift b/damus/ContentView.swift index 8681cb7e..470da9d0 100644 --- a/damus/ContentView.swift +++ b/damus/ContentView.swift @@ -252,7 +252,7 @@ struct ContentView: View { Button { isSideBarOpened.toggle() } label: { - ProfilePicView(pubkey: damus_state!.pubkey, size: 32, highlight: .none, profiles: damus_state!.profiles) + ProfilePicView(pubkey: damus_state!.pubkey, size: 32, highlight: .none, profiles: damus_state!.profiles, contacts: damus_state!.contacts) } } diff --git a/damus/Views/ChatView.swift b/damus/Views/ChatView.swift index 4654f350..43ed220d 100644 --- a/damus/Views/ChatView.swift +++ b/damus/Views/ChatView.swift @@ -75,7 +75,7 @@ struct ChatView: View { HStack { VStack { if is_active || just_started { - ProfilePicView(pubkey: event.pubkey, size: 32, highlight: is_active ? .main : .none, profiles: damus_state.profiles) + ProfilePicView(pubkey: event.pubkey, size: 32, highlight: is_active ? .main : .none, profiles: damus_state.profiles, contacts:damus_state.contacts) } Spacer() @@ -97,7 +97,7 @@ struct ChatView: View { if let ref_id = thread.replies.lookup(event.id) { if !is_reply_to_prev() { /* - ReplyQuoteView(keypair: damus_state.keypair, quoter: event, event_id: ref_id, profiles: damus_state.profiles, previews: damus_state.previews) + ReplyQuoteView(keypair: damus_state.keypair, quoter: event, event_id: ref_id, profiles: damus_state.profiles, previews: damus_state.previews, contacts: damus_state.contacts) .frame(maxHeight: expand_reply ? nil : 100) .environmentObject(thread) .onTapGesture { diff --git a/damus/Views/ConfigView.swift b/damus/Views/ConfigView.swift index 217469e4..0f69c8b4 100644 --- a/damus/Views/ConfigView.swift +++ b/damus/Views/ConfigView.swift @@ -19,8 +19,8 @@ struct ConfigView: View { @State var privkey_copied: Bool = false @State var pubkey_copied: Bool = false @State var delete_text: String = "" - @ObservedObject var settings: UserSettingsStore + @AppStorage("remote_image_policy") var remote_image_policy: String = "everyone" let generator = UIImpactFeedbackGenerator(style: .light) @@ -129,7 +129,30 @@ struct ConfigView: View { KingfisherManager.shared.cache.cleanExpiredDiskCache() } } - + + Section("Profile Image Loading Policy") { + Menu { + Button { + UserDefaults.standard.set("everyone", forKey:"remote_image_policy") + } label: { + Text("Everyone") + } + Button { + UserDefaults.standard.set("friends", forKey:"remote_image_policy") + } label: { + Text("Friends Only") + } + Button { + UserDefaults.standard.set("restricted", forKey:"remote_image_policy") + } label: { + Text("Restricted") + } + } label: { + Text("\(convertImageLoadPolicyTxt(policy:remote_image_policy))") + .frame(maxWidth: .infinity, alignment: .leading) + } + } + if state.is_privkey_user { Section(NSLocalizedString("Delete", comment: "Section title for deleting the user")) { Button(NSLocalizedString("Delete Account", comment: "Button to delete the user's account."), role: .destructive) { @@ -176,6 +199,17 @@ struct ConfigView: View { } } +func convertImageLoadPolicyTxt(policy: String) -> String { + switch policy { + case "restricted": + return "Restricted" + case "friends": + return "Friends Only" + default: + return "Everyone" + } +} + struct ConfigView_Previews: PreviewProvider { static var previews: some View { NavigationView { diff --git a/damus/Views/DMChatView.swift b/damus/Views/DMChatView.swift index e4858cd8..8a1f1ce1 100644 --- a/damus/Views/DMChatView.swift +++ b/damus/Views/DMChatView.swift @@ -42,7 +42,7 @@ struct DMChatView: View { let profile_page = ProfileView(damus_state: damus_state, profile: pmodel, followers: fmodel) return NavigationLink(destination: profile_page) { HStack { - ProfilePicView(pubkey: pubkey, size: 24, highlight: .none, profiles: damus_state.profiles) + ProfilePicView(pubkey: pubkey, size: 24, highlight: .none, profiles: damus_state.profiles, contacts:damus_state.contacts) ProfileName(pubkey: pubkey, profile: profile, damus: damus_state, show_friend_confirmed: true) } diff --git a/damus/Views/EventView.swift b/damus/Views/EventView.swift index ef4c61cc..a63e7974 100644 --- a/damus/Views/EventView.swift +++ b/damus/Views/EventView.swift @@ -104,7 +104,7 @@ struct EventView: View { let pv = ProfileView(damus_state: damus, profile: pmodel, followers: FollowersModel(damus_state: damus, target: pubkey)) NavigationLink(destination: pv) { - ProfilePicView(pubkey: pubkey, size: PFP_SIZE, highlight: .none, profiles: damus.profiles) + ProfilePicView(pubkey: pubkey, size: PFP_SIZE, highlight: .none, profiles: damus.profiles, contacts: damus.contacts) } Spacer() diff --git a/damus/Views/ProfilePicView.swift b/damus/Views/ProfilePicView.swift index 09742372..b4ac298b 100644 --- a/damus/Views/ProfilePicView.swift +++ b/damus/Views/ProfilePicView.swift @@ -98,19 +98,21 @@ struct ProfilePicView: View { let size: CGFloat let highlight: Highlight let profiles: Profiles + let contacts: Contacts @State var picture: String? - init (pubkey: String, size: CGFloat, highlight: Highlight, profiles: Profiles, picture: String? = nil) { + init (pubkey: String, size: CGFloat, highlight: Highlight, profiles: Profiles, contacts: Contacts, picture: String? = nil) { self.pubkey = pubkey self.profiles = profiles + self.contacts = contacts self.size = size self.highlight = highlight self._picture = State(initialValue: picture) } var body: some View { - InnerProfilePicView(url: get_profile_url(picture: picture, pubkey: pubkey, profiles: profiles), fallbackUrl: URL(string: robohash(pubkey)), pubkey: pubkey, size: size, highlight: highlight) + InnerProfilePicView(url: get_profile_url(picture: picture, pubkey: pubkey, profiles: profiles, contacts: contacts), fallbackUrl: URL(string: robohash(pubkey)), pubkey: pubkey, size: size, highlight: highlight) .onReceive(handle_notify(.profile_updated)) { notif in let updated = notif.object as! ProfileUpdate @@ -126,7 +128,14 @@ struct ProfilePicView: View { } func get_profile_url(picture: String?, pubkey: String, profiles: Profiles) -> URL { - let pic = picture ?? profiles.lookup(id: pubkey)?.picture ?? robohash(pubkey) + var pic: String + let remote_image_policy = UserDefaults.standard.string(forKey: "remote_image_policy") + if remote_image_policy == "restricted" || (remote_image_policy == "friends" && !contacts.is_friend(pubkey)) { + pic = robohash(pubkey) + } else { + pic = picture ?? profiles.lookup(id: pubkey)?.picture ?? robohash(pubkey) + } + if let url = URL(string: pic) { return url } @@ -150,7 +159,8 @@ struct ProfilePicView_Previews: PreviewProvider { pubkey: pubkey, size: 100, highlight: .none, - profiles: make_preview_profiles(pubkey)) + profiles: make_preview_profiles(pubkey), + contacts: Contacts()) } } diff --git a/damus/Views/ProfilePictureSelector.swift b/damus/Views/ProfilePictureSelector.swift index 6eeac672..4abba4a3 100644 --- a/damus/Views/ProfilePictureSelector.swift +++ b/damus/Views/ProfilePictureSelector.swift @@ -13,7 +13,7 @@ struct ProfilePictureSelector: View { var body: some View { let highlight: Highlight = .custom(Color.white, 2.0) ZStack { - ProfilePicView(pubkey: pubkey, size: 80.0, highlight: highlight, profiles: Profiles()) + ProfilePicView(pubkey: pubkey, size: 80.0, highlight: highlight, profiles: Profiles(), contacts: Contacts()) } } } From 63dd39c7e4f85d5b29cf6101a444311ecd17bc17 Mon Sep 17 00:00:00 2001 From: Thomas <31560900+0xtlt@users.noreply.github.com> Date: Sat, 24 Dec 2022 13:30:12 +0100 Subject: [PATCH 2/3] Using enum --- damus/Views/ConfigView.swift | 46 ++++++++++++++++++-------------- damus/Views/ProfilePicView.swift | 5 ++-- 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/damus/Views/ConfigView.swift b/damus/Views/ConfigView.swift index 0f69c8b4..3ddd6f0d 100644 --- a/damus/Views/ConfigView.swift +++ b/damus/Views/ConfigView.swift @@ -8,6 +8,23 @@ import AVFoundation import Kingfisher import SwiftUI +enum RemoteImagePolicy: String, CaseIterable { + case everyone + case friendsOnly + case restricted +} + +func remoteImagePolicyText(_ fs: RemoteImagePolicy) -> String { + switch fs { + case .everyone: + return "Everyone" + case .friendsOnly: + return "Friends Only" + case .restricted: + return "Restricted (no remote image)" + } +} + struct ConfigView: View { let state: DamusState @Environment(\.dismiss) var dismiss @@ -19,8 +36,8 @@ struct ConfigView: View { @State var privkey_copied: Bool = false @State var pubkey_copied: Bool = false @State var delete_text: String = "" - @ObservedObject var settings: UserSettingsStore - @AppStorage("remote_image_policy") var remote_image_policy: String = "everyone" + @EnvironmentObject var user_settings: UserSettingsStore + @AppStorage("remote_image_policy") var remote_image_policy: RemoteImagePolicy = .everyone let generator = UIImpactFeedbackGenerator(style: .light) @@ -133,22 +150,22 @@ struct ConfigView: View { Section("Profile Image Loading Policy") { Menu { Button { - UserDefaults.standard.set("everyone", forKey:"remote_image_policy") + self.remote_image_policy = .everyone } label: { - Text("Everyone") + Text(remoteImagePolicyText(.everyone)) } Button { - UserDefaults.standard.set("friends", forKey:"remote_image_policy") + self.remote_image_policy = .friendsOnly } label: { - Text("Friends Only") + Text(remoteImagePolicyText(.friendsOnly)) } Button { - UserDefaults.standard.set("restricted", forKey:"remote_image_policy") + self.remote_image_policy = .restricted } label: { - Text("Restricted") + Text(remoteImagePolicyText(.restricted)) } } label: { - Text("\(convertImageLoadPolicyTxt(policy:remote_image_policy))") + Text("\(remoteImagePolicyText(remote_image_policy))") .frame(maxWidth: .infinity, alignment: .leading) } } @@ -199,17 +216,6 @@ struct ConfigView: View { } } -func convertImageLoadPolicyTxt(policy: String) -> String { - switch policy { - case "restricted": - return "Restricted" - case "friends": - return "Friends Only" - default: - return "Everyone" - } -} - struct ConfigView_Previews: PreviewProvider { static var previews: some View { NavigationView { diff --git a/damus/Views/ProfilePicView.swift b/damus/Views/ProfilePicView.swift index b4ac298b..1ce2a21d 100644 --- a/damus/Views/ProfilePicView.swift +++ b/damus/Views/ProfilePicView.swift @@ -129,8 +129,9 @@ struct ProfilePicView: View { func get_profile_url(picture: String?, pubkey: String, profiles: Profiles) -> URL { var pic: String - let remote_image_policy = UserDefaults.standard.string(forKey: "remote_image_policy") - if remote_image_policy == "restricted" || (remote_image_policy == "friends" && !contacts.is_friend(pubkey)) { + let remote_image_policy: RemoteImagePolicy = RemoteImagePolicy(rawValue: UserDefaults.standard.string(forKey: "remote_image_policy")!) ?? .everyone + + if remote_image_policy == .restricted || (remote_image_policy == .friendsOnly && !contacts.is_friend(pubkey)) { pic = robohash(pubkey) } else { pic = picture ?? profiles.lookup(id: pubkey)?.picture ?? robohash(pubkey) From 1a2e9464afa00167385652d0f4bca3c87d688400 Mon Sep 17 00:00:00 2001 From: radixrat Date: Sat, 24 Dec 2022 09:56:23 -0500 Subject: [PATCH 3/3] add friends of friends, apply to all images --- damus/Components/TranslateView.swift | 3 ++- damus/Components/UserView.swift | 2 +- damus/Views/ConfigView.swift | 16 ++++++++++++---- damus/Views/EditMetadataView.swift | 2 +- damus/Views/EventView.swift | 10 ++++++++-- damus/Views/Events/EventProfile.swift | 2 +- damus/Views/NoteContentView.swift | 12 ++++++------ damus/Views/ParicipantsView.swift | 2 +- damus/Views/ProfilePicView.swift | 15 +++++++++------ damus/Views/ProfilePictureSelector.swift | 2 +- damus/Views/ProfileView.swift | 4 ++-- damus/Views/ProfileZoomView.swift | 7 +++++-- damus/Views/SideMenuView.swift | 2 +- 13 files changed, 50 insertions(+), 29 deletions(-) diff --git a/damus/Components/TranslateView.swift b/damus/Components/TranslateView.swift index 9a104868..4465f97c 100644 --- a/damus/Components/TranslateView.swift +++ b/damus/Components/TranslateView.swift @@ -121,7 +121,8 @@ struct TranslateView: View { if let translated = translated_note { // Render translated note. let blocks = event.get_blocks(content: translated) - translated_artifacts = render_blocks(blocks: blocks, profiles: damus_state.profiles, privkey: damus_state.keypair.privkey) + let show_images = should_show_images(contacts: damus_state.contacts, ev: event, our_pubkey: damus_state.pubkey) + translated_artifacts = render_blocks(blocks: blocks, profiles: damus_state.profiles, privkey: damus_state.keypair.privkey, show_images: show_images) } checkingTranslationStatus = false diff --git a/damus/Components/UserView.swift b/damus/Components/UserView.swift index 721a5f40..a6ec8b4a 100644 --- a/damus/Components/UserView.swift +++ b/damus/Components/UserView.swift @@ -17,7 +17,7 @@ struct UserView: View { let pv = ProfileView(damus_state: damus_state, profile: pmodel, followers: followers) NavigationLink(destination: pv) { - ProfilePicView(pubkey: pubkey, size: PFP_SIZE, highlight: .none, profiles: damus_state.profiles) + ProfilePicView(pubkey: pubkey, size: PFP_SIZE, highlight: .none, profiles: damus_state.profiles, contacts: damus_state.contacts) VStack(alignment: .leading) { let profile = damus_state.profiles.lookup(id: pubkey) diff --git a/damus/Views/ConfigView.swift b/damus/Views/ConfigView.swift index 3ddd6f0d..586a9f8b 100644 --- a/damus/Views/ConfigView.swift +++ b/damus/Views/ConfigView.swift @@ -11,6 +11,7 @@ import SwiftUI enum RemoteImagePolicy: String, CaseIterable { case everyone case friendsOnly + case friendsOfFriends case restricted } @@ -20,8 +21,10 @@ func remoteImagePolicyText(_ fs: RemoteImagePolicy) -> String { return "Everyone" case .friendsOnly: return "Friends Only" + case .friendsOfFriends: + return "Friends of Friends" case .restricted: - return "Restricted (no remote image)" + return "Block Images" } } @@ -36,8 +39,8 @@ struct ConfigView: View { @State var privkey_copied: Bool = false @State var pubkey_copied: Bool = false @State var delete_text: String = "" - @EnvironmentObject var user_settings: UserSettingsStore - @AppStorage("remote_image_policy") var remote_image_policy: RemoteImagePolicy = .everyone + @ObservedObject var settings: UserSettingsStore + @AppStorage("remote_image_policy") var remote_image_policy: RemoteImagePolicy = .friendsOfFriends let generator = UIImpactFeedbackGenerator(style: .light) @@ -147,13 +150,18 @@ struct ConfigView: View { } } - Section("Profile Image Loading Policy") { + Section(NSLocalizedString("Remote Image Loading Policy", comment: "Section title for remote image loading policy")) { Menu { Button { self.remote_image_policy = .everyone } label: { Text(remoteImagePolicyText(.everyone)) } + Button { + self.remote_image_policy = .friendsOfFriends + } label: { + Text(remoteImagePolicyText(.friendsOfFriends)) + } Button { self.remote_image_policy = .friendsOnly } label: { diff --git a/damus/Views/EditMetadataView.swift b/damus/Views/EditMetadataView.swift index a12ef199..bf6ae2bc 100644 --- a/damus/Views/EditMetadataView.swift +++ b/damus/Views/EditMetadataView.swift @@ -120,7 +120,7 @@ struct EditMetadataView: View { let pfp_size: CGFloat = 90.0 HStack(alignment: .center) { - ProfilePicView(pubkey: damus_state.pubkey, size: pfp_size, highlight: .custom(imageBorderColor(), 4.0), profiles: damus_state.profiles) + ProfilePicView(pubkey: damus_state.pubkey, size: pfp_size, highlight: .custom(imageBorderColor(), 4.0), profiles: damus_state.profiles, contacts: damus_state.contacts) .offset(y: -(pfp_size/2.0)) // Increase if set a frame Spacer() diff --git a/damus/Views/EventView.swift b/damus/Views/EventView.swift index a63e7974..bbc6e08d 100644 --- a/damus/Views/EventView.swift +++ b/damus/Views/EventView.swift @@ -151,12 +151,18 @@ func should_show_images(contacts: Contacts, ev: NostrEvent, our_pubkey: String, if ev.pubkey == our_pubkey { return true } - if contacts.is_in_friendosphere(ev.pubkey) { + + let remote_image_policy: RemoteImagePolicy = RemoteImagePolicy(rawValue: UserDefaults.standard.string(forKey: "remote_image_policy") ?? "") ?? .friendsOfFriends + if remote_image_policy == .everyone || + remote_image_policy == .friendsOnly && contacts.is_friend(ev.pubkey) || + remote_image_policy == .friendsOfFriends && contacts.is_in_friendosphere(ev.pubkey) { return true } - if let boost_key = booster_pubkey, contacts.is_in_friendosphere(boost_key) { + + if let boost_key = booster_pubkey, contacts.is_in_friendosphere(boost_key) && remote_image_policy != .restricted { return true } + return false } diff --git a/damus/Views/Events/EventProfile.swift b/damus/Views/Events/EventProfile.swift index 17ef625e..cf7be340 100644 --- a/damus/Views/Events/EventProfile.swift +++ b/damus/Views/Events/EventProfile.swift @@ -35,7 +35,7 @@ struct EventProfile: View { let pv = ProfileView(damus_state: damus_state, profile: pmodel, followers: FollowersModel(damus_state: damus_state, target: pubkey)) NavigationLink(destination: pv) { - ProfilePicView(pubkey: pubkey, size: pfp_size, highlight: .none, profiles: damus_state.profiles) + ProfilePicView(pubkey: pubkey, size: pfp_size, highlight: .none, profiles: damus_state.profiles, contacts: damus_state.contacts) } } diff --git a/damus/Views/NoteContentView.swift b/damus/Views/NoteContentView.swift index bb492c91..10beded2 100644 --- a/damus/Views/NoteContentView.swift +++ b/damus/Views/NoteContentView.swift @@ -65,7 +65,7 @@ struct NoteContentView: View { var body: some View { MainContent() .onAppear() { - self.artifacts = render_note_content(ev: event, profiles: damus_state.profiles, privkey: damus_state.keypair.privkey) + self.artifacts = render_note_content(ev: event, profiles: damus_state.profiles, privkey: damus_state.keypair.privkey, show_images: show_images) } .onReceive(handle_notify(.profile_updated)) { notif in let profile = notif.object as! ProfileUpdate @@ -74,7 +74,7 @@ struct NoteContentView: View { switch block { case .mention(let m): if m.type == .pubkey && m.ref.ref_id == profile.pubkey { - self.artifacts = render_note_content(ev: event, profiles: damus_state.profiles, privkey: damus_state.keypair.privkey) + self.artifacts = render_note_content(ev: event, profiles: damus_state.profiles, privkey: damus_state.keypair.privkey, show_images: show_images) } case .text: return case .hashtag: return @@ -261,12 +261,12 @@ struct NoteArtifacts { } } -func render_note_content(ev: NostrEvent, profiles: Profiles, privkey: String?) -> NoteArtifacts { +func render_note_content(ev: NostrEvent, profiles: Profiles, privkey: String?, show_images: Bool) -> NoteArtifacts { let blocks = ev.blocks(privkey) - return render_blocks(blocks: blocks, profiles: profiles, privkey: privkey) + return render_blocks(blocks: blocks, profiles: profiles, privkey: privkey, show_images: show_images) } -func render_blocks(blocks: [Block], profiles: Profiles, privkey: String?) -> NoteArtifacts { +func render_blocks(blocks: [Block], profiles: Profiles, privkey: String?, show_images: Bool) -> NoteArtifacts { var invoices: [Invoice] = [] var img_urls: [URL] = [] var link_urls: [URL] = [] @@ -283,7 +283,7 @@ func render_blocks(blocks: [Block], profiles: Profiles, privkey: String?) -> Not return str case .url(let url): // Handle Image URLs - if is_image_url(url) { + if show_images && is_image_url(url) { // Append Image img_urls.append(url) return str diff --git a/damus/Views/ParicipantsView.swift b/damus/Views/ParicipantsView.swift index 720a3e84..75ec693d 100644 --- a/damus/Views/ParicipantsView.swift +++ b/damus/Views/ParicipantsView.swift @@ -39,7 +39,7 @@ struct ParticipantsView: View { ForEach(originalReferences.pRefs) { participant in let pubkey = participant.id HStack { - ProfilePicView(pubkey: pubkey, size: PFP_SIZE, highlight: .none, profiles: damus_state.profiles) + ProfilePicView(pubkey: pubkey, size: PFP_SIZE, highlight: .none, profiles: damus_state.profiles, contacts: damus_state.contacts) VStack(alignment: .leading) { let profile = damus_state.profiles.lookup(id: pubkey) diff --git a/damus/Views/ProfilePicView.swift b/damus/Views/ProfilePicView.swift index 1ce2a21d..d6822d78 100644 --- a/damus/Views/ProfilePicView.swift +++ b/damus/Views/ProfilePicView.swift @@ -127,14 +127,17 @@ struct ProfilePicView: View { } } -func get_profile_url(picture: String?, pubkey: String, profiles: Profiles) -> URL { +func get_profile_url(picture: String?, pubkey: String, profiles: Profiles, contacts: Contacts) -> URL { var pic: String - let remote_image_policy: RemoteImagePolicy = RemoteImagePolicy(rawValue: UserDefaults.standard.string(forKey: "remote_image_policy")!) ?? .everyone + let remote_image_policy: RemoteImagePolicy = RemoteImagePolicy(rawValue: UserDefaults.standard.string(forKey: "remote_image_policy") ?? "") ?? .friendsOfFriends - if remote_image_policy == .restricted || (remote_image_policy == .friendsOnly && !contacts.is_friend(pubkey)) { - pic = robohash(pubkey) - } else { + if pubkey == contacts.our_pubkey || + remote_image_policy == .everyone || + remote_image_policy == .friendsOnly && contacts.is_friend(pubkey) || + remote_image_policy == .friendsOfFriends && contacts.is_in_friendosphere(pubkey) { pic = picture ?? profiles.lookup(id: pubkey)?.picture ?? robohash(pubkey) + } else { + pic = robohash(pubkey) } if let url = URL(string: pic) { @@ -161,7 +164,7 @@ struct ProfilePicView_Previews: PreviewProvider { size: 100, highlight: .none, profiles: make_preview_profiles(pubkey), - contacts: Contacts()) + contacts: Contacts(our_pubkey: pubkey)) } } diff --git a/damus/Views/ProfilePictureSelector.swift b/damus/Views/ProfilePictureSelector.swift index 4abba4a3..7ef4fc63 100644 --- a/damus/Views/ProfilePictureSelector.swift +++ b/damus/Views/ProfilePictureSelector.swift @@ -13,7 +13,7 @@ struct ProfilePictureSelector: View { var body: some View { let highlight: Highlight = .custom(Color.white, 2.0) ZStack { - ProfilePicView(pubkey: pubkey, size: 80.0, highlight: highlight, profiles: Profiles(), contacts: Contacts()) + ProfilePicView(pubkey: pubkey, size: 80.0, highlight: highlight, profiles: Profiles(), contacts: Contacts(our_pubkey: pubkey)) } } } diff --git a/damus/Views/ProfileView.swift b/damus/Views/ProfileView.swift index 48082a92..f0fd7512 100644 --- a/damus/Views/ProfileView.swift +++ b/damus/Views/ProfileView.swift @@ -254,12 +254,12 @@ struct ProfileView: View { let pfp_size: CGFloat = 90.0 HStack(alignment: .center) { - ProfilePicView(pubkey: profile.pubkey, size: pfp_size, highlight: .custom(imageBorderColor(), 4.0), profiles: damus_state.profiles) + ProfilePicView(pubkey: profile.pubkey, size: pfp_size, highlight: .custom(imageBorderColor(), 4.0), profiles: damus_state.profiles, contacts: damus_state.contacts) .onTapGesture { is_zoomed.toggle() } .fullScreenCover(isPresented: $is_zoomed) { - ProfileZoomView(pubkey: profile.pubkey, profiles: damus_state.profiles) } + ProfileZoomView(pubkey: profile.pubkey, profiles: damus_state.profiles, contacts: damus_state.contacts)} .offset(y: -(pfp_size/2.0)) // Increase if set a frame Spacer() diff --git a/damus/Views/ProfileZoomView.swift b/damus/Views/ProfileZoomView.swift index 16d8eed0..14d6308b 100644 --- a/damus/Views/ProfileZoomView.swift +++ b/damus/Views/ProfileZoomView.swift @@ -11,6 +11,7 @@ struct ProfileZoomView: View { @Environment(\.presentationMode) var presentationMode let pubkey: String let profiles: Profiles + let contacts: Contacts @GestureState private var scaleState: CGFloat = 1 @GestureState private var offsetState = CGSize.zero @@ -68,7 +69,7 @@ struct ProfileZoomView: View { Spacer() - ProfilePicView(pubkey: pubkey, size: 200.0, highlight: .none, profiles: profiles) + ProfilePicView(pubkey: pubkey, size: 200.0, highlight: .none, profiles: profiles, contacts: contacts) .padding(100) .scaledToFit() .scaleEffect(self.scale * scaleState) @@ -92,6 +93,8 @@ struct ProfileZoomView_Previews: PreviewProvider { static var previews: some View { ProfileZoomView( pubkey: pubkey, - profiles: make_preview_profiles(pubkey)) + profiles: make_preview_profiles(pubkey), + contacts: Contacts(our_pubkey: pubkey) + ) } } diff --git a/damus/Views/SideMenuView.swift b/damus/Views/SideMenuView.swift index 5e3c48ce..03275954 100644 --- a/damus/Views/SideMenuView.swift +++ b/damus/Views/SideMenuView.swift @@ -55,7 +55,7 @@ struct SideMenuView: View { NavigationLink(destination: ProfileView(damus_state: damus_state, profile: profile_model, followers: followers)) { if let picture = damus_state.profiles.lookup(id: damus_state.pubkey)?.picture { - ProfilePicView(pubkey: damus_state.pubkey, size: 60, highlight: .none, profiles: damus_state.profiles, picture: picture) + ProfilePicView(pubkey: damus_state.pubkey, size: 60, highlight: .none, profiles: damus_state.profiles, contacts: damus_state.contacts, picture: picture) } else { Image(systemName: "person.fill") }