From 944cb97043272df486c42e6f0f6d8a52845f603a Mon Sep 17 00:00:00 2001 From: Sneh Date: Thu, 9 Jan 2025 16:45:14 +0530 Subject: [PATCH] minor changes --- .../ui/flow/settings/space/SpaceProfileViewModel.kt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/canopas/yourspace/ui/flow/settings/space/SpaceProfileViewModel.kt b/app/src/main/java/com/canopas/yourspace/ui/flow/settings/space/SpaceProfileViewModel.kt index 5847bdde..e7f3e03a 100644 --- a/app/src/main/java/com/canopas/yourspace/ui/flow/settings/space/SpaceProfileViewModel.kt +++ b/app/src/main/java/com/canopas/yourspace/ui/flow/settings/space/SpaceProfileViewModel.kt @@ -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 + ) + ) } } }