Compare commits
1 Commits
tyiu/new-n
...
tyiu/post-
| Author | SHA1 | Date | |
|---|---|---|---|
|
4d333907bd
|
@@ -79,13 +79,27 @@ struct PostView: View {
|
||||
|
||||
post.enumerateAttributes(in: NSRange(location: 0, length: post.length), options: []) { attributes, range, stop in
|
||||
if let link = attributes[.link] as? String {
|
||||
post.replaceCharacters(in: range, with: link)
|
||||
let normalized_link: String
|
||||
if link.hasPrefix("damus:nostr:") {
|
||||
// Replace damus:nostr: URI prefix with nostr: since the former is for internal navigation and not meant to be posted.
|
||||
normalized_link = String(link.dropFirst(6))
|
||||
} else {
|
||||
normalized_link = link
|
||||
}
|
||||
|
||||
// Add zero-width space in case text preceding the mention is not a whitespace.
|
||||
// In the case where the character preceding the mention is a whitespace, the added zero-width space will be stripped out.
|
||||
post.replaceCharacters(in: range, with: "\u{200B}\(normalized_link)\u{200B}")
|
||||
}
|
||||
}
|
||||
|
||||
var content = self.post.string
|
||||
// If two zero-width spaces are next to each other, normalize it to just one zero-width space.
|
||||
.replacingOccurrences(of: "\u{200B}\u{200B}", with: "\u{200B}")
|
||||
// If zero-width space is next to an actual whitespace, remove the zero-width space.
|
||||
.replacingOccurrences(of: " \u{200B}", with: " ")
|
||||
.replacingOccurrences(of: "\u{200B} ", with: " ")
|
||||
.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
|
||||
.replacingOccurrences(of: "\u{200B}", with: "") // these characters are added when adding mentions.
|
||||
|
||||
let imagesString = uploadedMedias.map { $0.uploadedURL.absoluteString }.joined(separator: " ")
|
||||
|
||||
|
||||
@@ -63,7 +63,8 @@ struct UserSearch: View {
|
||||
|
||||
let tagAttributedString = NSMutableAttributedString(string: tagString,
|
||||
attributes: [NSAttributedString.Key.font: UIFont.systemFont(ofSize: 18.0),
|
||||
NSAttributedString.Key.link: "nostr:\(pk)"])
|
||||
// Add damus: URI so that taps within the post creation view redirect internally within Damus instead of redirecting to a different Nostr client. The damus: prefix will be stripped out prior to sending the note to relays.
|
||||
NSAttributedString.Key.link: "damus:nostr:\(pk)"])
|
||||
tagAttributedString.removeAttribute(.link, range: NSRange(location: tagAttributedString.length - 2, length: 2))
|
||||
tagAttributedString.addAttributes([NSAttributedString.Key.foregroundColor: UIColor.label], range: NSRange(location: tagAttributedString.length - 2, length: 2))
|
||||
|
||||
|
||||
@@ -466,69 +466,61 @@ struct ProfileView: View {
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
ScrollView(.vertical) {
|
||||
VStack(spacing: 0) {
|
||||
bannerSection
|
||||
.zIndex(1)
|
||||
ScrollView(.vertical) {
|
||||
VStack(spacing: 0) {
|
||||
bannerSection
|
||||
.zIndex(1)
|
||||
|
||||
VStack() {
|
||||
aboutSection
|
||||
|
||||
VStack(spacing: 0) {
|
||||
CustomPicker(selection: $filter_state, content: {
|
||||
Text("Notes", comment: "Label for filter for seeing only your notes (instead of notes and replies).").tag(FilterState.posts)
|
||||
Text("Notes & Replies", comment: "Label for filter for seeing your notes and replies (instead of only your notes).").tag(FilterState.posts_and_replies)
|
||||
})
|
||||
Divider()
|
||||
.frame(height: 1)
|
||||
}
|
||||
.background(colorScheme == .dark ? Color.black : Color.white)
|
||||
|
||||
VStack() {
|
||||
aboutSection
|
||||
|
||||
VStack(spacing: 0) {
|
||||
CustomPicker(selection: $filter_state, content: {
|
||||
Text("Notes", comment: "Label for filter for seeing only your notes (instead of notes and replies).").tag(FilterState.posts)
|
||||
Text("Notes & Replies", comment: "Label for filter for seeing your notes and replies (instead of only your notes).").tag(FilterState.posts_and_replies)
|
||||
})
|
||||
Divider()
|
||||
.frame(height: 1)
|
||||
}
|
||||
.background(colorScheme == .dark ? Color.black : Color.white)
|
||||
|
||||
if filter_state == FilterState.posts {
|
||||
InnerTimelineView(events: profile.events, damus: damus_state, filter: FilterState.posts.filter)
|
||||
}
|
||||
if filter_state == FilterState.posts_and_replies {
|
||||
InnerTimelineView(events: profile.events, damus: damus_state, filter: FilterState.posts_and_replies.filter)
|
||||
}
|
||||
if filter_state == FilterState.posts {
|
||||
InnerTimelineView(events: profile.events, damus: damus_state, filter: FilterState.posts.filter)
|
||||
}
|
||||
.padding(.horizontal, Theme.safeAreaInsets?.left)
|
||||
.zIndex(-yOffset > navbarHeight ? 0 : 1)
|
||||
}
|
||||
}
|
||||
.ignoresSafeArea()
|
||||
.navigationTitle("")
|
||||
.navigationBarHidden(true)
|
||||
.overlay(customNavbar, alignment: .top)
|
||||
.onReceive(handle_notify(.switched_timeline)) { _ in
|
||||
dismiss()
|
||||
}
|
||||
.onAppear() {
|
||||
profile.subscribe()
|
||||
//followers.subscribe()
|
||||
}
|
||||
.onDisappear {
|
||||
profile.unsubscribe()
|
||||
followers.unsubscribe()
|
||||
// our profilemodel needs a bit more help
|
||||
}
|
||||
.sheet(isPresented: $show_share_sheet) {
|
||||
if let npub = bech32_pubkey(profile.pubkey) {
|
||||
if let url = URL(string: "https://damus.io/" + npub) {
|
||||
ShareSheet(activityItems: [url])
|
||||
if filter_state == FilterState.posts_and_replies {
|
||||
InnerTimelineView(events: profile.events, damus: damus_state, filter: FilterState.posts_and_replies.filter)
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, Theme.safeAreaInsets?.left)
|
||||
.zIndex(-yOffset > navbarHeight ? 0 : 1)
|
||||
}
|
||||
.fullScreenCover(isPresented: $show_qr_code) {
|
||||
QRCodeView(damus_state: damus_state, pubkey: profile.pubkey)
|
||||
}
|
||||
|
||||
if profile.pubkey == damus_state.pubkey && damus_state.is_privkey_user {
|
||||
PostButtonContainer(is_left_handed: damus_state.settings.left_handed) {
|
||||
notify(.compose, PostAction.posting)
|
||||
}
|
||||
.ignoresSafeArea()
|
||||
.navigationTitle("")
|
||||
.navigationBarHidden(true)
|
||||
.overlay(customNavbar, alignment: .top)
|
||||
.onReceive(handle_notify(.switched_timeline)) { _ in
|
||||
dismiss()
|
||||
}
|
||||
.onAppear() {
|
||||
profile.subscribe()
|
||||
//followers.subscribe()
|
||||
}
|
||||
.onDisappear {
|
||||
profile.unsubscribe()
|
||||
followers.unsubscribe()
|
||||
// our profilemodel needs a bit more help
|
||||
}
|
||||
.sheet(isPresented: $show_share_sheet) {
|
||||
if let npub = bech32_pubkey(profile.pubkey) {
|
||||
if let url = URL(string: "https://damus.io/" + npub) {
|
||||
ShareSheet(activityItems: [url])
|
||||
}
|
||||
}
|
||||
}
|
||||
.fullScreenCover(isPresented: $show_qr_code) {
|
||||
QRCodeView(damus_state: damus_state, pubkey: profile.pubkey)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user