Remove flowOn in LoadingViewModel

This commit is contained in:
Andrew 2024-06-21 11:45:50 +09:30
parent b7de36b694
commit 27c59a8d7b
2 changed files with 10 additions and 7 deletions

View File

@ -49,24 +49,27 @@ internal class LoadingViewModel @Inject constructor(
.onStart { emit(TextSecurePreferences.CONFIGURATION_SYNCED) } .onStart { emit(TextSecurePreferences.CONFIGURATION_SYNCED) }
.filter { prefs.getConfigurationMessageSynced() } .filter { prefs.getConfigurationMessageSynced() }
.timeout(TIMEOUT_TIME) .timeout(TIMEOUT_TIME)
.flowOn(Dispatchers.Main)
.collectLatest { onSuccess() } .collectLatest { onSuccess() }
} catch (e: Exception) { } catch (e: Exception) {
withContext(Dispatchers.Main) { onFail() } onFail()
} }
} }
} }
private suspend fun onSuccess() { private suspend fun onSuccess() {
withContext(Dispatchers.Main) {
_states.value = State(ANIMATE_TO_DONE_TIME) _states.value = State(ANIMATE_TO_DONE_TIME)
delay(IDLE_DONE_TIME) delay(IDLE_DONE_TIME)
_events.emit(Event.SUCCESS) _events.emit(Event.SUCCESS)
} }
}
private suspend fun onFail() { private suspend fun onFail() {
withContext(Dispatchers.Main) {
_events.emit(Event.TIMEOUT) _events.emit(Event.TIMEOUT)
} }
} }
}
sealed interface Event { sealed interface Event {
object SUCCESS: Event object SUCCESS: Event

View File

@ -40,7 +40,7 @@ interface Colors {
val backgroundBubbleSent: Color get() = primary val backgroundBubbleSent: Color get() = primary
// buttonFill // buttonFill
val buttonFill: Color get() = text val buttonFill: Color
val buttonFillText: Color get() = background val buttonFillText: Color get() = background
// primaryButtonFill // primaryButtonFill