Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
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
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ private fun HandleToastMessages(

LaunchedEffect(key1 = error) {
if (error.isNotEmpty()) {
viewModel.sendStreamChatMessage(error)
viewModel.sendStreamChatMessage("$error: ${context.getString(R.string.toast_hello)}")
}
}
}
2 changes: 1 addition & 1 deletion feature-chat/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
<string name="stream_top_bar">Stream</string>
<string name="toast_success_create_channel">A random ChatGPT channel is created!</string>
<string name="toast_hello">Hi, I\'m OpenAI\'s ChatGPT with Stream SDK. Ask me anything!</string>
<string name="toast_error">Something went wrong</string>
<string name="toast_error">Something went wrong. Please re-install this app.</string>
<string name="toast_error_session">Something went wrong. Please check out your session and CF_CLEARANCE is valid.</string>
</resources>