Skip to content

Commit

Permalink
fix: profile soft loop bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Wylwi committed Dec 19, 2024
1 parent 03bd1f5 commit b1a7af8
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,12 @@ open class ProfileViewModel(private val repository: ProfileRepository) : ViewMod
fun getProfileById(id: String) {
repository.getProfileById(
id,
onSuccess = { profile -> profile_.value = profile },
onSuccess = { profile ->
profile_.value = profile
_errorMessageId.value = null
},
onFailure = {
profile_.value = null
Log.e("ProfileViewModel", "Error fetching profile", it)
_errorMessageId.value = R.string.an_error_occurred_while_fetching_the_profile
})
Expand All @@ -62,7 +66,10 @@ open class ProfileViewModel(private val repository: ProfileRepository) : ViewMod
fun updateProfile(profile: Profile) {
repository.updateProfile(
profile = profile,
onSuccess = { profile_.value = profile },
onSuccess = {
profile_.value = profile
_errorMessageId.value = null
},
onFailure = {
Log.e("ProfileViewModel", "Error updating profile", it)
_errorMessageId.value = R.string.an_error_occurred_while_updating_the_profile
Expand All @@ -77,7 +84,10 @@ open class ProfileViewModel(private val repository: ProfileRepository) : ViewMod
fun deleteProfileById(id: String) {
repository.deleteProfileById(
id = id,
onSuccess = { profile_.value = null },
onSuccess = {
profile_.value = null
_errorMessageId.value = null
},
onFailure = {
Log.e("ProfileViewModel", "Error deleting profile", it)
_errorMessageId.value = R.string.an_error_occurred_while_deleting_the_profile
Expand Down

0 comments on commit b1a7af8

Please sign in to comment.