1
0
Fork 0
mirror of https://github.com/anyproto/anytype-kotlin.git synced 2025-06-08 05:47:05 +09:00

DROID-2966 Chats | Fix | Misc. fixes (#2489)

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Evgenii Kozlov 2025-06-02 17:11:35 +02:00 committed by GitHub
parent 4582af43bf
commit e5f771b836
Signed by: github
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 5 deletions

View file

@ -381,6 +381,7 @@ class ChatViewModel @Inject constructor(
selection: IntRange,
text: String
) {
Timber.d("DROID-2966 onChatBoxInputChanged")
val query = resolveMentionQuery(
text = text,
selectionStart = selection.start
@ -393,7 +394,7 @@ class ChatViewModel @Inject constructor(
query = query
)
} else {
Timber.w("Query is empty or results are empty when mention is triggered")
Timber.w("DROID-2966 Query is empty or results are empty when mention is triggered")
}
} else if (shouldHideMention(text, selection.start)) {
mentionPanelState.value = MentionPanelState.Hidden
@ -1045,10 +1046,15 @@ class ChatViewModel @Inject constructor(
private fun resolveMentionQuery(text: String, selectionStart: Int): MentionPanelState.Query? {
val atIndex = text.lastIndexOf('@', selectionStart - 1)
if (atIndex == -1 || (atIndex > 0 && text[atIndex - 1].isLetterOrDigit())) return null
val endIndex = text.indexOf(' ', atIndex).takeIf { it != -1 } ?: text.length
if (atIndex == -1) return null
val beforeAt = text.getOrNull(atIndex - 1)
if (beforeAt != null && beforeAt.isLetterOrDigit()) return null
val endIndex = text.indexOfAny(charArrayOf(' ', '\n'), startIndex = atIndex)
.takeIf { it != -1 } ?: text.length
val query = text.substring(atIndex + 1, endIndex)
// Allow empty queries if there's no space after '@'
return MentionPanelState.Query(query, atIndex until endIndex)
}

View file

@ -339,7 +339,7 @@ fun Bubble(
DropdownMenuItem(
text = {
Text(
text = stringResource(R.string.copy_text),
text = stringResource(R.string.copy_plain_text),
color = colorResource(id = R.color.text_primary),
modifier = Modifier.padding(end = 64.dp)
)