Skip to content

Commit

Permalink
✨ :: Add collect to deleteDeviceToken
Browse files Browse the repository at this point in the history
  • Loading branch information
diejdkll committed Jul 22, 2024
1 parent b8ef541 commit 9929329
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ class MainActivityViewModel @Inject constructor(
private val _saveDeviceTokenUiState = MutableStateFlow<Result<Unit>>(Result.Loading)
val saveDeviceTokenUiState = _saveDeviceTokenUiState.asStateFlow()

private val _deleteDeviceTokenUiState = MutableStateFlow<Result<Unit>>(Result.Loading)
val deleteDeviceTokenUiState = _deleteDeviceTokenUiState.asStateFlow()

private val _themeState = MutableStateFlow(ResourceKeys.EMPTY)
val themeState = _themeState.asStateFlow()

Expand All @@ -90,6 +93,15 @@ class MainActivityViewModel @Inject constructor(

fun deleteDeviceToken() = viewModelScope.launch {
deleteDeviceTokenUseCase()
.onSuccess {
it.catch { remoteError ->
_deleteDeviceTokenUiState.value = Result.Error(remoteError)
}.collect { result ->
_deleteDeviceTokenUiState.value = Result.Success(result)
}
}.onFailure {
_deleteDeviceTokenUiState.value = Result.Error(it)
}
}

fun deleteToken() = viewModelScope.launch {
Expand Down

0 comments on commit 9929329

Please sign in to comment.