Fixes user search/list not resetting

Fixes modifier bug
This commit is contained in:
Vitor Pamplona
2026-03-09 08:43:29 -04:00
parent af4404c86e
commit 961b8cf19e
19 changed files with 52 additions and 20 deletions
@@ -96,6 +96,7 @@ import com.vitorpamplona.amethyst.ui.theme.QuoteBorder
import com.vitorpamplona.amethyst.ui.theme.Size10dp
import com.vitorpamplona.amethyst.ui.theme.Size5dp
import com.vitorpamplona.amethyst.ui.theme.StdVertSpacer
import com.vitorpamplona.amethyst.ui.theme.SuggestionListDefaultHeightPage
import com.vitorpamplona.amethyst.ui.theme.placeholderText
import com.vitorpamplona.amethyst.ui.theme.replyModifier
import com.vitorpamplona.amethyst.ui.theme.subtleBorder
@@ -344,7 +345,7 @@ fun EditPostView(
it,
postViewModel::autocompleteWithUser,
accountViewModel,
modifier = Modifier.heightIn(0.dp, 300.dp),
modifier = SuggestionListDefaultHeightPage,
)
}
@@ -278,6 +278,9 @@ open class EditPostViewModel : ViewModel() {
if (lastWord.startsWith("@")) {
userSuggestionsMainMessage = UserSuggestionAnchor.MAIN_MESSAGE
userSuggestions?.processCurrentWord(lastWord)
} else {
userSuggestionsMainMessage = null
userSuggestions?.reset()
}
}
}
@@ -24,7 +24,6 @@ import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement.spacedBy
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyColumn
@@ -55,7 +54,7 @@ fun ShowEmojiSuggestionList(
emojiSuggestions: EmojiSuggestionState,
onSelect: (EmojiPackState.EmojiMedia) -> Unit,
onFullSize: (EmojiPackState.EmojiMedia) -> Unit,
modifier: Modifier = Modifier.heightIn(0.dp, 200.dp),
modifier: Modifier = Modifier,
) {
val suggestions by emojiSuggestions.results.collectAsStateWithLifecycle(emptyList())
@@ -55,7 +55,7 @@ fun ShowUserSuggestionList(
userSuggestions: UserSuggestionState,
onSelect: (User) -> Unit,
accountViewModel: AccountViewModel,
modifier: Modifier = Modifier.heightIn(0.dp, 200.dp),
modifier: Modifier = Modifier,
) {
UserSearchDataSourceSubscription(userSuggestions, accountViewModel)
@@ -67,8 +67,10 @@ class UserSuggestionState(
}.flowOn(Dispatchers.IO)
fun reset() {
if (!currentWord.value.isEmpty()) {
currentWord.tryEmit("")
}
}
fun processCurrentWord(word: String) {
currentWord.tryEmit(word)
@@ -588,6 +588,9 @@ open class CommentPostViewModel :
if (lastWord.startsWith("@")) {
userSuggestionsMainMessage = UserSuggestionAnchor.MAIN_MESSAGE
userSuggestions?.processCurrentWord(lastWord)
} else {
userSuggestionsMainMessage = null
userSuggestions?.reset()
}
emojiSuggestions?.processCurrentWord(lastWord)
@@ -30,7 +30,6 @@ import androidx.compose.foundation.layout.consumeWindowInsets
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
@@ -83,6 +82,7 @@ import com.vitorpamplona.amethyst.ui.theme.Size10dp
import com.vitorpamplona.amethyst.ui.theme.Size35dp
import com.vitorpamplona.amethyst.ui.theme.Size5dp
import com.vitorpamplona.amethyst.ui.theme.StdVertSpacer
import com.vitorpamplona.amethyst.ui.theme.SuggestionListDefaultHeightPage
import com.vitorpamplona.amethyst.ui.theme.replyModifier
import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.toImmutableList
@@ -346,7 +346,7 @@ private fun GenericCommentPostBody(
it,
postViewModel::autocompleteWithUser,
accountViewModel,
modifier = Modifier.heightIn(0.dp, 300.dp),
modifier = SuggestionListDefaultHeightPage,
)
}
@@ -355,7 +355,7 @@ private fun GenericCommentPostBody(
it,
postViewModel::autocompleteWithEmoji,
postViewModel::autocompleteWithEmojiUrl,
modifier = Modifier.heightIn(0.dp, 300.dp),
modifier = SuggestionListDefaultHeightPage,
)
}
@@ -569,6 +569,9 @@ class ChatNewMessageViewModel :
if (lastWord.startsWith("@")) {
userSuggestionsMainMessage = UserSuggestionAnchor.MAIN_MESSAGE
userSuggestions?.processCurrentWord(lastWord)
} else {
userSuggestionsMainMessage = null
userSuggestions?.reset()
}
emojiSuggestions?.processCurrentWord(lastWord)
}
@@ -32,7 +32,6 @@ import androidx.compose.foundation.layout.consumeWindowInsets
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyRow
@@ -121,6 +120,7 @@ import com.vitorpamplona.amethyst.ui.theme.QuoteBorder
import com.vitorpamplona.amethyst.ui.theme.Size10dp
import com.vitorpamplona.amethyst.ui.theme.Size35dp
import com.vitorpamplona.amethyst.ui.theme.Size5dp
import com.vitorpamplona.amethyst.ui.theme.SuggestionListDefaultHeightPage
import com.vitorpamplona.amethyst.ui.theme.placeholderText
import kotlinx.collections.immutable.persistentListOf
import kotlinx.coroutines.Dispatchers
@@ -299,7 +299,7 @@ fun GroupDMScreenContent(
it,
postViewModel::autocompleteWithUser,
accountViewModel,
Modifier.heightIn(0.dp, 300.dp),
SuggestionListDefaultHeightPage,
)
}
@@ -308,7 +308,7 @@ fun GroupDMScreenContent(
it,
postViewModel::autocompleteWithEmoji,
postViewModel::autocompleteWithEmojiUrl,
Modifier.heightIn(0.dp, 300.dp),
SuggestionListDefaultHeightPage,
)
}
@@ -57,6 +57,7 @@ import com.vitorpamplona.amethyst.ui.theme.EditFieldModifier
import com.vitorpamplona.amethyst.ui.theme.EditFieldTrailingIconModifier
import com.vitorpamplona.amethyst.ui.theme.Font12SP
import com.vitorpamplona.amethyst.ui.theme.PostKeyboard
import com.vitorpamplona.amethyst.ui.theme.SuggestionListDefaultHeightChat
import com.vitorpamplona.amethyst.ui.theme.ThemeComparisonColumn
import com.vitorpamplona.amethyst.ui.theme.placeholderText
@@ -119,6 +120,7 @@ fun PrivateMessageEditFieldRow(
it,
channelScreenModel::autocompleteWithUser,
accountViewModel,
SuggestionListDefaultHeightChat,
)
}
@@ -127,6 +129,7 @@ fun PrivateMessageEditFieldRow(
it,
channelScreenModel::autocompleteWithEmoji,
channelScreenModel::autocompleteWithEmojiUrl,
SuggestionListDefaultHeightChat,
)
}
@@ -532,6 +532,9 @@ open class ChannelNewMessageViewModel :
if (lastWord.startsWith("@")) {
userSuggestionsMainMessage = UserSuggestionAnchor.MAIN_MESSAGE
userSuggestions?.processCurrentWord(lastWord)
} else {
userSuggestionsMainMessage = null
userSuggestions?.reset()
}
emojiSuggestions?.processCurrentWord(lastWord)
@@ -50,6 +50,7 @@ import com.vitorpamplona.amethyst.ui.stringRes
import com.vitorpamplona.amethyst.ui.theme.EditFieldBorder
import com.vitorpamplona.amethyst.ui.theme.EditFieldModifier
import com.vitorpamplona.amethyst.ui.theme.EditFieldTrailingIconModifier
import com.vitorpamplona.amethyst.ui.theme.SuggestionListDefaultHeightChat
import com.vitorpamplona.amethyst.ui.theme.placeholderText
import kotlinx.coroutines.FlowPreview
@@ -96,6 +97,7 @@ fun EditFieldRow(
it,
channelScreenModel::autocompleteWithUser,
accountViewModel,
SuggestionListDefaultHeightChat,
)
}
@@ -104,6 +106,7 @@ fun EditFieldRow(
it,
channelScreenModel::autocompleteWithEmoji,
channelScreenModel::autocompleteWithEmojiUrl,
SuggestionListDefaultHeightChat,
)
}
@@ -29,7 +29,6 @@ import androidx.compose.foundation.layout.consumeWindowInsets
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
@@ -79,6 +78,7 @@ import com.vitorpamplona.amethyst.ui.stringRes
import com.vitorpamplona.amethyst.ui.theme.Size10dp
import com.vitorpamplona.amethyst.ui.theme.Size35dp
import com.vitorpamplona.amethyst.ui.theme.Size5dp
import com.vitorpamplona.amethyst.ui.theme.SuggestionListDefaultHeightPage
import kotlinx.collections.immutable.persistentListOf
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.FlowPreview
@@ -314,7 +314,7 @@ private fun NewProductBody(
it,
postViewModel::autocompleteWithUser,
accountViewModel,
modifier = Modifier.heightIn(0.dp, 300.dp),
modifier = SuggestionListDefaultHeightPage,
)
}
@@ -323,7 +323,7 @@ private fun NewProductBody(
it,
postViewModel::autocompleteWithEmoji,
postViewModel::autocompleteWithEmojiUrl,
modifier = Modifier.heightIn(0.dp, 300.dp),
modifier = SuggestionListDefaultHeightPage,
)
}
@@ -488,6 +488,9 @@ open class NewProductViewModel :
if (lastWord.startsWith("@")) {
userSuggestionsMainMessage = UserSuggestionAnchor.MAIN_MESSAGE
userSuggestions?.processCurrentWord(lastWord)
} else {
userSuggestionsMainMessage = null
userSuggestions?.reset()
}
emojiSuggestions?.processCurrentWord(lastWord)
@@ -33,7 +33,6 @@ import androidx.compose.foundation.layout.consumeWindowInsets
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
@@ -104,6 +103,7 @@ import com.vitorpamplona.amethyst.ui.theme.Size10dp
import com.vitorpamplona.amethyst.ui.theme.Size35dp
import com.vitorpamplona.amethyst.ui.theme.Size5dp
import com.vitorpamplona.amethyst.ui.theme.StdVertSpacer
import com.vitorpamplona.amethyst.ui.theme.SuggestionListDefaultHeightPage
import com.vitorpamplona.amethyst.ui.theme.ThemeComparisonColumn
import com.vitorpamplona.amethyst.ui.theme.replyModifier
import kotlinx.collections.immutable.persistentListOf
@@ -449,7 +449,7 @@ private fun NewPostScreenBody(
it,
postViewModel::autocompleteWithUser,
accountViewModel,
modifier = Modifier.heightIn(0.dp, 300.dp),
modifier = SuggestionListDefaultHeightPage,
)
}
@@ -458,7 +458,7 @@ private fun NewPostScreenBody(
it,
postViewModel::autocompleteWithEmoji,
postViewModel::autocompleteWithEmojiUrl,
modifier = Modifier.heightIn(0.dp, 300.dp),
modifier = SuggestionListDefaultHeightPage,
)
}
@@ -934,6 +934,9 @@ open class ShortNotePostViewModel :
if (lastWord.startsWith("@")) {
userSuggestionsMainMessage = UserSuggestionAnchor.MAIN_MESSAGE
userSuggestions?.processCurrentWord(lastWord)
} else {
userSuggestionsMainMessage = null
userSuggestions?.reset()
}
emojiSuggestions?.processCurrentWord(lastWord)
@@ -29,7 +29,6 @@ import androidx.compose.foundation.layout.consumeWindowInsets
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
@@ -91,6 +90,7 @@ import com.vitorpamplona.amethyst.ui.theme.DividerThickness
import com.vitorpamplona.amethyst.ui.theme.Font14SP
import com.vitorpamplona.amethyst.ui.theme.Size10dp
import com.vitorpamplona.amethyst.ui.theme.Size5dp
import com.vitorpamplona.amethyst.ui.theme.SuggestionListDefaultHeightPage
import com.vitorpamplona.amethyst.ui.theme.imageModifier
import com.vitorpamplona.amethyst.ui.theme.placeholderText
import com.vitorpamplona.quartz.nip01Core.core.HexKey
@@ -273,7 +273,7 @@ fun PublicMessageScreenContent(
it,
postViewModel::autocompleteWithUser,
accountViewModel,
Modifier.heightIn(0.dp, 300.dp),
SuggestionListDefaultHeightPage,
)
}
@@ -282,7 +282,7 @@ fun PublicMessageScreenContent(
it,
postViewModel::autocompleteWithEmoji,
postViewModel::autocompleteWithEmojiUrl,
Modifier.heightIn(0.dp, 300.dp),
SuggestionListDefaultHeightPage,
)
}
@@ -526,6 +526,9 @@ class NewPublicMessageViewModel :
if (lastWord.startsWith("@")) {
userSuggestionsMainMessage = UserSuggestionAnchor.MAIN_MESSAGE
userSuggestions?.processCurrentWord(lastWord)
} else {
userSuggestionsMainMessage = null
userSuggestions?.reset()
}
emojiSuggestions?.processCurrentWord(lastWord)
@@ -383,4 +383,7 @@ val PopupUpEffect = RoundedCornerShape(0.dp, 0.dp, 15.dp, 15.dp)
val Size50ModifierOffset10 = Modifier.size(50.dp).offset(y = (-10).dp)
val SuggestionListDefaultHeightChat = Modifier.heightIn(0.dp, 200.dp)
val SuggestionListDefaultHeightPage = Modifier.heightIn(0.dp, 300.dp)
val FollowPackHeaderModifier = Modifier.fillMaxWidth().height(TopBarSize)