From 79090bab226eb2a6c9f8c13a0240939beea42954 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 18 Jun 2024 12:18:14 +0930 Subject: [PATCH] Use MutablesharedFlow in NewMessage --- .../conversation/newmessage/NewMessageViewModel.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/newmessage/NewMessageViewModel.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/newmessage/NewMessageViewModel.kt index 8551722c15..a7e370fdbf 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/newmessage/NewMessageViewModel.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/newmessage/NewMessageViewModel.kt @@ -9,7 +9,9 @@ import kotlinx.coroutines.Job import kotlinx.coroutines.TimeoutCancellationException import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.receiveAsFlow import kotlinx.coroutines.flow.update @@ -31,8 +33,8 @@ internal class NewMessageViewModel @Inject constructor( private val _state = MutableStateFlow(State()) val state = _state.asStateFlow() - private val _success = Channel() - val success: Flow get() = _success.receiveAsFlow() + private val _success = MutableSharedFlow() + val success: Flow get() = _success.asSharedFlow() private val _qrErrors = Channel() val qrErrors: Flow = _qrErrors.receiveAsFlow() @@ -91,7 +93,7 @@ internal class NewMessageViewModel @Inject constructor( private fun onPublicKey(publicKey: String) { _state.update { it.copy(loading = false) } - viewModelScope.launch { _success.send(Success(publicKey)) } + viewModelScope.launch { _success.emit(Success(publicKey)) } } private fun onUnvalidatedPublicKey(publicKey: String) {