Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-sneh-s committed Jan 9, 2025
1 parent 803a006 commit 944cb97
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,24 @@ class SpaceProfileViewModel @Inject constructor(
fun updateMemberLocation(memberId: String, enableLocation: Boolean) {
viewModelScope.launch(appDispatcher.IO) {
try {
_state.emit(_state.value.copy(userLocationUpdatingId = memberId))
spaceRepository.enableLocation(spaceID, memberId, enableLocation)
val spaceInfo = spaceRepository.getSpaceInfo(spaceID)
_state.emit(
_state.value.copy(
spaceInfo = spaceInfo,
locationEnabledChanges = mapOf(memberId to enableLocation)
locationEnabledChanges = _state.value.locationEnabledChanges + (memberId to enableLocation),
userLocationUpdatingId = null
)
)
} catch (e: Exception) {
Timber.e(e, "Failed to update member location")
_state.emit(_state.value.copy(error = e))
_state.emit(
_state.value.copy(
error = e,
userLocationUpdatingId = null
)
)
}
}
}
Expand Down

0 comments on commit 944cb97

Please sign in to comment.