Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Reset the ui state toast
  • Loading branch information
skydoves committed Dec 16, 2022
commit 468fae012d1d0e7726e03cb628a6a1b476da0aa5
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ import androidx.lifecycle.viewModelScope
import com.skydoves.chatgpt.core.data.repository.GPTChannelRepository
import dagger.hilt.android.lifecycle.HiltViewModel
import io.getstream.chat.android.client.utils.onError
import io.getstream.chat.android.client.utils.onSuccess
import io.getstream.chat.android.client.utils.onSuccessSuspend
import javax.inject.Inject
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.launch
Expand Down Expand Up @@ -54,8 +55,10 @@ class ChatGPTChannelsViewModel @Inject constructor(
viewModelScope.launch {
channelsMutableUiState.value = GPTChannelUiState.Loading
val result = gptChannelRepository.createRandomChannel()
result.onSuccess {
result.onSuccessSuspend {
channelsMutableUiState.value = GPTChannelUiState.Success(it.id)
delay(100L)
channelsMutableUiState.value = GPTChannelUiState.Nothing
}.onError {
channelsMutableUiState.value = GPTChannelUiState.Error
}
Expand Down