damus

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

commit a65351154baf96d88515970ebe0ebce2ac6caf08
parent 2e2b33e21ded2a0e82f2eff0ac3030a282a8ab2a
Author: William Casarin <jb55@jb55.com>
Date:   Fri, 17 Mar 2023 11:33:15 -0600

Make it much easier to tag users in replies and posts

Changelog-Changed: It's much easier to tag users in replies and posts

Diffstat:
Mdamus/Models/ProfileModel.swift | 11+++++++----
Mdamus/Views/PostView.swift | 27++++++++++++++-------------
Mdamus/Views/ReplyView.swift | 18++++++++++++++----
3 files changed, 35 insertions(+), 21 deletions(-)

diff --git a/damus/Models/ProfileModel.swift b/damus/Models/ProfileModel.swift @@ -12,10 +12,12 @@ class ProfileModel: ObservableObject, Equatable { @Published var contacts: NostrEvent? = nil @Published var following: Int = 0 @Published var relays: [String: RelayInfo]? = nil + @Published var progress: Int = 0 let pubkey: String let damus: DamusState + var seen_event: Set<String> = Set() var sub_id = UUID().description var prof_subid = UUID().description @@ -127,15 +129,16 @@ class ProfileModel: ObservableObject, Equatable { case .ws_event: return case .nostr_event(let resp): + guard resp.subid == self.sub_id || resp.subid == self.prof_subid else { + return + } switch resp { - case .event(let sid, let ev): - if sid != self.sub_id && sid != self.prof_subid { - return - } + case .event(_, let ev): add_event(ev) case .notice(let notice): notify(.notice, notice) case .eose: + progress += 1 break } } diff --git a/damus/Views/PostView.swift b/damus/Views/PostView.swift @@ -190,7 +190,9 @@ struct PostView: View { } var body: some View { - VStack(alignment: .leading) { + VStack(alignment: .leading, spacing: 0) { + let searching = get_searching_string(post.string) + TopBar HStack(alignment: .top) { @@ -198,20 +200,20 @@ struct PostView: View { TextEntry } - + .frame(maxHeight: searching == nil ? .infinity : 50) + // This if-block observes @ for tagging - if let searching = get_searching_string(post.string) { - VStack { - Spacer() - UserSearch(damus_state: damus_state, search: searching, post: $post) - }.zIndex(1) + if let searching { + UserSearch(damus_state: damus_state, search: searching, post: $post) + .frame(maxHeight: .infinity) + } else { + Divider() + .padding([.bottom], 10) + + AttachmentBar } - - Divider() - .padding([.bottom], 10) - - AttachmentBar } + .padding() .sheet(isPresented: $attach_media) { ImagePicker(sourceType: .photoLibrary) { img in handle_upload(image: img) @@ -240,7 +242,6 @@ struct PostView: View { damus_state.drafts.post = NSMutableAttributedString(string : "") } } - .padding() .alert(NSLocalizedString("Note contains \"nsec1\" private key. Are you sure?", comment: "Alert user that they might be attempting to paste a private key and ask them to confirm."), isPresented: $showPrivateKeyWarning, actions: { Button(NSLocalizedString("No", comment: "Button to cancel out of posting a note after being alerted that it looks like they might be posting a private key."), role: .cancel) { showPrivateKeyWarning = false diff --git a/damus/Views/ReplyView.swift b/damus/Views/ReplyView.swift @@ -26,6 +26,7 @@ struct ReplyView: View { var body: some View { VStack { Text("Replying to:", comment: "Indicating that the user is replying to the following listed people.") + HStack(alignment: .top) { let names = references.pRefs .map { pubkey in @@ -44,16 +45,25 @@ struct ReplyView: View { .sheet(isPresented: $participantsShown) { ParticipantsView(damus_state: damus, references: $references, originalReferences: $originalReferences) } - ScrollView { - EventView(damus: damus, event: replying_to, options: [.no_action_bar]) + + ScrollViewReader { scroller in + ScrollView { + EventView(damus: damus, event: replying_to, options: [.no_action_bar]) + + PostView(replying_to: replying_to, references: references, damus_state: damus) + .frame(minHeight: 500, maxHeight: .infinity) + .id("post") + } + .frame(maxHeight: .infinity) + .onAppear { + scroll_to_event(scroller: scroller, id: "post", delay: 1.0, animate: true, anchor: .top) + } } - PostView(replying_to: replying_to, references: references, damus_state: damus) } .onAppear { references = gather_reply_ids(our_pubkey: damus.pubkey, from: replying_to) originalReferences = references } - .padding() }