Skip to content
This repository has been archived by the owner on Sep 27, 2024. It is now read-only.

Commit

Permalink
Fix review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jmartinesp committed Nov 6, 2023
1 parent 8bfa70a commit 3cc816c
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ class MainActivity : ComponentActivity() {

val state = rememberRichTextEditorState(initialFocus = true)

Timber.d("Mentions state: ${state.mentionsState}")

LaunchedEffect(state.menuAction) {
processMenuAction(state.menuAction, roomMemberSuggestions)
}
Expand Down Expand Up @@ -130,7 +128,7 @@ class MainActivity : ComponentActivity() {
SuggestionView(
modifier = Modifier.heightIn(max = 320.dp),
roomMemberSuggestions = roomMemberSuggestions,
onReplaceSuggestionText = { text ->
onReplaceSuggestion = { text ->
coroutineScope.launch {
state.replaceSuggestion(text)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import uniffi.wysiwyg_composer.PatternKey
fun SuggestionView(
modifier: Modifier = Modifier,
roomMemberSuggestions: SnapshotStateList<Mention>,
onReplaceSuggestionText: (String) -> Unit,
onReplaceSuggestion: (String) -> Unit,
onInsertMentionAtSuggestion: (text: String, link: String) -> Unit,
onInsertAtRoomMentionAtSuggestion: () -> Unit,
) {
Expand All @@ -38,8 +38,8 @@ fun SuggestionView(
Mention.NotifyEveryone -> {
onInsertAtRoomMentionAtSuggestion()
}
is Mention.Command -> {
onReplaceSuggestionText(item.text)
is Mention.SlashCommand -> {
onReplaceSuggestion(item.text)
}
is Mention.Room -> {
// TODO Handle room mention
Expand Down Expand Up @@ -75,12 +75,12 @@ private fun processSuggestion(suggestion: MenuAction.Suggestion, roomMemberSugge
val text = suggestion.suggestionPattern.text
val people = listOf("alice", "bob", "carol", "dan").map(Mention::User)
val rooms = listOf("matrix", "element").map(Mention::Room)
val commands = listOf("leave", "shrug").map(Mention::Command)
val slashCommands = listOf("leave", "shrug").map(Mention::SlashCommand)
val everyone = Mention.NotifyEveryone
val names = when (suggestion.suggestionPattern.key) {
PatternKey.AT -> people + everyone
PatternKey.HASH -> rooms
PatternKey.SLASH -> commands
PatternKey.SLASH -> slashCommands
}
val suggestions = names
.filter { it.display.contains(text) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ sealed class Mention(
override val key: String = "@"
}

class Command(
class SlashCommand(
display: String
): Mention(display) {
override val key: String = "/"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ class RichTextEditor : LinearLayout {
item.link, item.text
)
}
Timber.d("Mentions state: ${binding.richTextEditText.getMentionsState()}}")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import io.element.android.wysiwyg.display.TextDisplay
import io.element.android.wysiwyg.utils.RustErrorCollector
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import timber.log.Timber


/**
Expand Down Expand Up @@ -174,7 +173,6 @@ private fun RealEditor(
// more than it's strictly necessary. To avoid this, we can use a `remember` block to cache the `update` lambda, and only update it when needed.
update = remember(style, typeface, mentionDisplayHandler, onError) {
{ view ->
Timber.d("RealEditor's update block called, recomposing!")
view.applyStyleInCompose(style)
view.typeface = typeface
view.updateStyle(style.toStyleConfig(view.context), mentionDisplayHandler)
Expand Down

0 comments on commit 3cc816c

Please sign in to comment.