Skip to content

Commit daa6260

Browse files
committed
Fix typing indicator and trim
1 parent 7c033e1 commit daa6260

File tree

1 file changed

+9
-6
lines changed
  • app/src/main/java/com/troplo/privateuploader/screens

1 file changed

+9
-6
lines changed

Diff for: app/src/main/java/com/troplo/privateuploader/screens/Chat.kt

+9-6
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ import com.troplo.privateuploader.data.model.Message
7575
import com.troplo.privateuploader.data.model.MessageEvent
7676
import com.troplo.privateuploader.data.model.MessageRequest
7777
import kotlinx.coroutines.Dispatchers
78+
import kotlinx.coroutines.delay
7879
import kotlinx.coroutines.launch
7980
import kotlinx.coroutines.withContext
8081
import org.json.JSONObject
@@ -143,6 +144,13 @@ fun ChatScreen(
143144
}
144145
}
145146

147+
LaunchedEffect(message.value) {
148+
if (message.value.isNotEmpty()) {
149+
chatViewModel.typing(associationId)
150+
}
151+
delay(3000)
152+
}
153+
146154
Scaffold(
147155
bottomBar = {
148156
if (editId.value != 0) {
@@ -225,11 +233,6 @@ fun ChatScreen(
225233
Text("${message.value.length}/4000")
226234
}
227235
},
228-
keyboardActions = KeyboardActions(
229-
onAny = {
230-
chatViewModel.typing(associationId)
231-
}
232-
),
233236
trailingIcon = {
234237
IconButton(
235238
onClick = {
@@ -531,7 +534,7 @@ class ChatViewModel : ViewModel() {
531534
id,
532535
chatId = associationId,
533536
userId = user.id,
534-
content = message,
537+
content = message.trim(),
535538
createdAt = TpuFunctions.currentISODate(),
536539
updatedAt = TpuFunctions.currentISODate(),
537540
user = user,

0 commit comments

Comments
 (0)