1
0
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:
gladiusKatana 2023-03-13 02:36:43 -04:00 committed by William Casarin
parent 3c2f281c6d
commit 1e7d9a6373

View File

@ -170,24 +170,20 @@ struct PostView: View {
}
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
}
guard last_word.count >= 2 else {
return nil
}
guard last_word.first! == "@" else {
guard handle.count >= 2 else {
return nil
}
// don't include @npub... strings
guard last_word.count != 64 else {
guard handle.count != 64 else {
return nil
}
return String(last_word.dropFirst())
return String(handle.dropFirst())
}
struct PostView_Previews: PreviewProvider {