mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-30 13:35:18 +00:00
Use MutablesharedFlow in NewMessage
This commit is contained in:
parent
90ddc9805a
commit
79090bab22
@ -9,7 +9,9 @@ import kotlinx.coroutines.Job
|
|||||||
import kotlinx.coroutines.TimeoutCancellationException
|
import kotlinx.coroutines.TimeoutCancellationException
|
||||||
import kotlinx.coroutines.channels.Channel
|
import kotlinx.coroutines.channels.Channel
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
|
import kotlinx.coroutines.flow.asSharedFlow
|
||||||
import kotlinx.coroutines.flow.asStateFlow
|
import kotlinx.coroutines.flow.asStateFlow
|
||||||
import kotlinx.coroutines.flow.receiveAsFlow
|
import kotlinx.coroutines.flow.receiveAsFlow
|
||||||
import kotlinx.coroutines.flow.update
|
import kotlinx.coroutines.flow.update
|
||||||
@ -31,8 +33,8 @@ internal class NewMessageViewModel @Inject constructor(
|
|||||||
private val _state = MutableStateFlow(State())
|
private val _state = MutableStateFlow(State())
|
||||||
val state = _state.asStateFlow()
|
val state = _state.asStateFlow()
|
||||||
|
|
||||||
private val _success = Channel<Success>()
|
private val _success = MutableSharedFlow<Success>()
|
||||||
val success: Flow<Success> get() = _success.receiveAsFlow()
|
val success: Flow<Success> get() = _success.asSharedFlow()
|
||||||
|
|
||||||
private val _qrErrors = Channel<String>()
|
private val _qrErrors = Channel<String>()
|
||||||
val qrErrors: Flow<String> = _qrErrors.receiveAsFlow()
|
val qrErrors: Flow<String> = _qrErrors.receiveAsFlow()
|
||||||
@ -91,7 +93,7 @@ internal class NewMessageViewModel @Inject constructor(
|
|||||||
|
|
||||||
private fun onPublicKey(publicKey: String) {
|
private fun onPublicKey(publicKey: String) {
|
||||||
_state.update { it.copy(loading = false) }
|
_state.update { it.copy(loading = false) }
|
||||||
viewModelScope.launch { _success.send(Success(publicKey)) }
|
viewModelScope.launch { _success.emit(Success(publicKey)) }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun onUnvalidatedPublicKey(publicKey: String) {
|
private fun onUnvalidatedPublicKey(publicKey: String) {
|
||||||
|
Loading…
Reference in New Issue
Block a user