Skip to content

Commit

Permalink
Fix typing indicator and trim
Browse files Browse the repository at this point in the history
  • Loading branch information
Troplo committed Jun 29, 2023
1 parent 7c033e1 commit daa6260
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions app/src/main/java/com/troplo/privateuploader/screens/Chat.kt
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ import com.troplo.privateuploader.data.model.Message
import com.troplo.privateuploader.data.model.MessageEvent
import com.troplo.privateuploader.data.model.MessageRequest
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.json.JSONObject
Expand Down Expand Up @@ -143,6 +144,13 @@ fun ChatScreen(
}
}

LaunchedEffect(message.value) {
if (message.value.isNotEmpty()) {
chatViewModel.typing(associationId)
}
delay(3000)
}

Scaffold(
bottomBar = {
if (editId.value != 0) {
Expand Down Expand Up @@ -225,11 +233,6 @@ fun ChatScreen(
Text("${message.value.length}/4000")
}
},
keyboardActions = KeyboardActions(
onAny = {
chatViewModel.typing(associationId)
}
),
trailingIcon = {
IconButton(
onClick = {
Expand Down Expand Up @@ -531,7 +534,7 @@ class ChatViewModel : ViewModel() {
id,
chatId = associationId,
userId = user.id,
content = message,
content = message.trim(),
createdAt = TpuFunctions.currentISODate(),
updatedAt = TpuFunctions.currentISODate(),
user = user,
Expand Down

0 comments on commit daa6260

Please sign in to comment.