mirror of
git://jb55.com/damus
synced 2024-10-06 11:43:21 +00:00
Fix mentions not working in middle of new note
Changelog-Fixed: Fix mentions not working in middle of new note Closes: #775
This commit is contained in:
parent
3c2f281c6d
commit
1e7d9a6373
@ -170,24 +170,20 @@ struct PostView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func get_searching_string(_ post: String) -> String? {
|
func get_searching_string(_ post: String) -> String? {
|
||||||
guard let last_word = post.components(separatedBy: .whitespacesAndNewlines).last else {
|
guard let handle = post.components(separatedBy: .whitespacesAndNewlines).first(where: {$0.first == "@"}) else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
guard last_word.count >= 2 else {
|
guard handle.count >= 2 else {
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
guard last_word.first! == "@" else {
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// don't include @npub... strings
|
// don't include @npub... strings
|
||||||
guard last_word.count != 64 else {
|
guard handle.count != 64 else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return String(last_word.dropFirst())
|
return String(handle.dropFirst())
|
||||||
}
|
}
|
||||||
|
|
||||||
struct PostView_Previews: PreviewProvider {
|
struct PostView_Previews: PreviewProvider {
|
||||||
|
Loading…
Reference in New Issue
Block a user