Make it much easier to tag users in replies and posts
Changelog-Changed: It's much easier to tag users in replies and posts
This commit is contained in:
@@ -12,10 +12,12 @@ class ProfileModel: ObservableObject, Equatable {
|
|||||||
@Published var contacts: NostrEvent? = nil
|
@Published var contacts: NostrEvent? = nil
|
||||||
@Published var following: Int = 0
|
@Published var following: Int = 0
|
||||||
@Published var relays: [String: RelayInfo]? = nil
|
@Published var relays: [String: RelayInfo]? = nil
|
||||||
|
@Published var progress: Int = 0
|
||||||
|
|
||||||
let pubkey: String
|
let pubkey: String
|
||||||
let damus: DamusState
|
let damus: DamusState
|
||||||
|
|
||||||
|
|
||||||
var seen_event: Set<String> = Set()
|
var seen_event: Set<String> = Set()
|
||||||
var sub_id = UUID().description
|
var sub_id = UUID().description
|
||||||
var prof_subid = UUID().description
|
var prof_subid = UUID().description
|
||||||
@@ -127,15 +129,16 @@ class ProfileModel: ObservableObject, Equatable {
|
|||||||
case .ws_event:
|
case .ws_event:
|
||||||
return
|
return
|
||||||
case .nostr_event(let resp):
|
case .nostr_event(let resp):
|
||||||
|
guard resp.subid == self.sub_id || resp.subid == self.prof_subid else {
|
||||||
|
return
|
||||||
|
}
|
||||||
switch resp {
|
switch resp {
|
||||||
case .event(let sid, let ev):
|
case .event(_, let ev):
|
||||||
if sid != self.sub_id && sid != self.prof_subid {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
add_event(ev)
|
add_event(ev)
|
||||||
case .notice(let notice):
|
case .notice(let notice):
|
||||||
notify(.notice, notice)
|
notify(.notice, notice)
|
||||||
case .eose:
|
case .eose:
|
||||||
|
progress += 1
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -190,7 +190,9 @@ struct PostView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack(alignment: .leading) {
|
VStack(alignment: .leading, spacing: 0) {
|
||||||
|
let searching = get_searching_string(post.string)
|
||||||
|
|
||||||
TopBar
|
TopBar
|
||||||
|
|
||||||
HStack(alignment: .top) {
|
HStack(alignment: .top) {
|
||||||
@@ -198,20 +200,20 @@ struct PostView: View {
|
|||||||
|
|
||||||
TextEntry
|
TextEntry
|
||||||
}
|
}
|
||||||
|
.frame(maxHeight: searching == nil ? .infinity : 50)
|
||||||
|
|
||||||
// This if-block observes @ for tagging
|
// This if-block observes @ for tagging
|
||||||
if let searching = get_searching_string(post.string) {
|
if let searching {
|
||||||
VStack {
|
UserSearch(damus_state: damus_state, search: searching, post: $post)
|
||||||
Spacer()
|
.frame(maxHeight: .infinity)
|
||||||
UserSearch(damus_state: damus_state, search: searching, post: $post)
|
} else {
|
||||||
}.zIndex(1)
|
Divider()
|
||||||
|
.padding([.bottom], 10)
|
||||||
|
|
||||||
|
AttachmentBar
|
||||||
}
|
}
|
||||||
|
|
||||||
Divider()
|
|
||||||
.padding([.bottom], 10)
|
|
||||||
|
|
||||||
AttachmentBar
|
|
||||||
}
|
}
|
||||||
|
.padding()
|
||||||
.sheet(isPresented: $attach_media) {
|
.sheet(isPresented: $attach_media) {
|
||||||
ImagePicker(sourceType: .photoLibrary) { img in
|
ImagePicker(sourceType: .photoLibrary) { img in
|
||||||
handle_upload(image: img)
|
handle_upload(image: img)
|
||||||
@@ -240,7 +242,6 @@ struct PostView: View {
|
|||||||
damus_state.drafts.post = NSMutableAttributedString(string : "")
|
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: {
|
.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) {
|
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
|
showPrivateKeyWarning = false
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ struct ReplyView: View {
|
|||||||
var body: some View {
|
var body: some View {
|
||||||
VStack {
|
VStack {
|
||||||
Text("Replying to:", comment: "Indicating that the user is replying to the following listed people.")
|
Text("Replying to:", comment: "Indicating that the user is replying to the following listed people.")
|
||||||
|
|
||||||
HStack(alignment: .top) {
|
HStack(alignment: .top) {
|
||||||
let names = references.pRefs
|
let names = references.pRefs
|
||||||
.map { pubkey in
|
.map { pubkey in
|
||||||
@@ -44,16 +45,25 @@ struct ReplyView: View {
|
|||||||
.sheet(isPresented: $participantsShown) {
|
.sheet(isPresented: $participantsShown) {
|
||||||
ParticipantsView(damus_state: damus, references: $references, originalReferences: $originalReferences)
|
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 {
|
.onAppear {
|
||||||
references = gather_reply_ids(our_pubkey: damus.pubkey, from: replying_to)
|
references = gather_reply_ids(our_pubkey: damus.pubkey, from: replying_to)
|
||||||
originalReferences = references
|
originalReferences = references
|
||||||
}
|
}
|
||||||
.padding()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user