diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/EditPostViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/EditPostViewModel.kt index 347c31d54..0de6c504c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/EditPostViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/EditPostViewModel.kt @@ -275,8 +275,10 @@ open class EditPostViewModel : ViewModel() { if (it.selection.collapsed) { val lastWord = message.currentWord() - userSuggestionsMainMessage = UserSuggestionAnchor.MAIN_MESSAGE - userSuggestions?.processCurrentWord(lastWord) + if (lastWord.startsWith("@")) { + userSuggestionsMainMessage = UserSuggestionAnchor.MAIN_MESSAGE + userSuggestions?.processCurrentWord(lastWord) + } } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/userSuggestions/UserSuggestionState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/userSuggestions/UserSuggestionState.kt index 955696d97..4e47b8b61 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/userSuggestions/UserSuggestionState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/creators/userSuggestions/UserSuggestionState.kt @@ -41,7 +41,6 @@ import kotlinx.coroutines.flow.update @Stable class UserSuggestionState( val account: Account, - val requireAtSymbol: Boolean = true, ) { val invalidations = MutableStateFlow(0) val currentWord = MutableStateFlow("") @@ -81,18 +80,10 @@ class UserSuggestionState( } fun userSearchTermOrNull(currentWord: String): String? = - if (requireAtSymbol) { - if (currentWord.startsWith("@") && currentWord.length > 2) { - currentWord.removePrefix("@") - } else { - null - } + if (currentWord.length > 2) { + currentWord.removePrefix("@") } else { - if (currentWord.length > 1) { - currentWord - } else { - null - } + null } fun updateDataSource(searchTerm: String?) { diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/nip22Comments/CommentPostViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/nip22Comments/CommentPostViewModel.kt index 239c41d63..b0a5f06a1 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/nip22Comments/CommentPostViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/nip22Comments/CommentPostViewModel.kt @@ -585,9 +585,10 @@ open class CommentPostViewModel : if (message.selection.collapsed) { val lastWord = message.currentWord() - - userSuggestionsMainMessage = UserSuggestionAnchor.MAIN_MESSAGE - userSuggestions?.processCurrentWord(lastWord) + if (lastWord.startsWith("@")) { + userSuggestionsMainMessage = UserSuggestionAnchor.MAIN_MESSAGE + userSuggestions?.processCurrentWord(lastWord) + } emojiSuggestions?.processCurrentWord(lastWord) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/send/ChatNewMessageViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/send/ChatNewMessageViewModel.kt index 108f67fd4..448b19bc5 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/send/ChatNewMessageViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/send/ChatNewMessageViewModel.kt @@ -565,10 +565,11 @@ class ChatNewMessageViewModel : urlPreviews.update(newMessage) if (message.selection.collapsed) { - userSuggestionsMainMessage = UserSuggestionAnchor.MAIN_MESSAGE - - val lastWord = message.currentWord() - userSuggestions?.processCurrentWord(lastWord) + val lastWord = newMessage.currentWord() + if (lastWord.startsWith("@")) { + userSuggestionsMainMessage = UserSuggestionAnchor.MAIN_MESSAGE + userSuggestions?.processCurrentWord(lastWord) + } emojiSuggestions?.processCurrentWord(lastWord) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/send/ChannelNewMessageViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/send/ChannelNewMessageViewModel.kt index 05db51ae1..2a536eb34 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/send/ChannelNewMessageViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/send/ChannelNewMessageViewModel.kt @@ -529,9 +529,10 @@ open class ChannelNewMessageViewModel : if (newMessage.selection.collapsed) { val lastWord = newMessage.currentWord() - - userSuggestionsMainMessage = UserSuggestionAnchor.MAIN_MESSAGE - userSuggestions?.processCurrentWord(lastWord) + if (lastWord.startsWith("@")) { + userSuggestionsMainMessage = UserSuggestionAnchor.MAIN_MESSAGE + userSuggestions?.processCurrentWord(lastWord) + } emojiSuggestions?.processCurrentWord(lastWord) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/NewProductViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/NewProductViewModel.kt index 1297036b6..08960d5f3 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/NewProductViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/NewProductViewModel.kt @@ -485,9 +485,10 @@ open class NewProductViewModel : if (message.selection.collapsed) { val lastWord = message.currentWord() - - userSuggestionsMainMessage = UserSuggestionAnchor.MAIN_MESSAGE - userSuggestions?.processCurrentWord(lastWord) + if (lastWord.startsWith("@")) { + userSuggestionsMainMessage = UserSuggestionAnchor.MAIN_MESSAGE + userSuggestions?.processCurrentWord(lastWord) + } emojiSuggestions?.processCurrentWord(lastWord) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/ShortNotePostViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/ShortNotePostViewModel.kt index db41c7152..2114bf14e 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/ShortNotePostViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/ShortNotePostViewModel.kt @@ -930,10 +930,11 @@ open class ShortNotePostViewModel : urlPreviews.update(message) if (message.selection.collapsed) { - val lastWord = message.currentWord() - - userSuggestionsMainMessage = UserSuggestionAnchor.MAIN_MESSAGE - userSuggestions?.processCurrentWord(lastWord) + val lastWord = newMessage.currentWord() + if (lastWord.startsWith("@")) { + userSuggestionsMainMessage = UserSuggestionAnchor.MAIN_MESSAGE + userSuggestions?.processCurrentWord(lastWord) + } emojiSuggestions?.processCurrentWord(lastWord) } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/display/lists/PeopleListViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/display/lists/PeopleListViewModel.kt index d360ba0eb..1c90d76de 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/display/lists/PeopleListViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/display/lists/PeopleListViewModel.kt @@ -71,7 +71,7 @@ class PeopleListViewModel : ViewModel() { ) { if (!this::account.isInitialized || this.account != account) { this.account = account - this.userSuggestions = UserSuggestionState(account, false) + this.userSuggestions = UserSuggestionState(account) } this.selectedDTag.tryEmit(selectedDTag) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/display/packs/FollowPackViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/display/packs/FollowPackViewModel.kt index e110d9cc1..228de46bb 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/display/packs/FollowPackViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/display/packs/FollowPackViewModel.kt @@ -71,7 +71,7 @@ class FollowPackViewModel : ViewModel() { ) { if (!this::account.isInitialized || this.account != account) { this.account = account - this.userSuggestions = UserSuggestionState(account, false) + this.userSuggestions = UserSuggestionState(account) } this.selectedDTag.tryEmit(selectedDTag) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/publicMessages/NewPublicMessageViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/publicMessages/NewPublicMessageViewModel.kt index daedcac62..8eeef1562 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/publicMessages/NewPublicMessageViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/publicMessages/NewPublicMessageViewModel.kt @@ -522,10 +522,12 @@ class NewPublicMessageViewModel : urlPreviews.update(newMessage) if (message.selection.collapsed) { - userSuggestionsMainMessage = UserSuggestionAnchor.MAIN_MESSAGE + val lastWord = newMessage.currentWord() + if (lastWord.startsWith("@")) { + userSuggestionsMainMessage = UserSuggestionAnchor.MAIN_MESSAGE + userSuggestions?.processCurrentWord(lastWord) + } - val lastWord = message.currentWord() - userSuggestions?.processCurrentWord(lastWord) emojiSuggestions?.processCurrentWord(lastWord) }