Show locate button only when current user is not sharing live location

This commit is contained in:
Maxime NATUREL 2023-02-16 17:51:54 +01:00
parent 8eff831382
commit f676a65544
3 changed files with 5 additions and 2 deletions

View File

@ -194,7 +194,7 @@ class LiveLocationMapViewFragment :
updateMap(viewState.userLocations)
}
updateUserListBottomSheet(viewState.userLocations)
updateLocateButton(showLocateButton = false)
updateLocateButton(showLocateButton = viewState.showLocateButton)
}
private fun updateUserListBottomSheet(userLocations: List<UserLiveLocationViewState>) {

View File

@ -28,10 +28,12 @@ import im.vector.app.features.location.live.tracking.LocationSharingServiceConne
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
import org.matrix.android.sdk.api.session.Session
import org.matrix.android.sdk.api.session.room.location.UpdateLiveLocationShareResult
class LiveLocationMapViewModel @AssistedInject constructor(
@Assisted private val initialState: LiveLocationMapViewState,
private val session: Session,
getListOfUserLiveLocationUseCase: GetListOfUserLiveLocationUseCase,
private val locationSharingServiceConnection: LocationSharingServiceConnection,
private val stopLiveLocationShareUseCase: StopLiveLocationShareUseCase,
@ -46,7 +48,7 @@ class LiveLocationMapViewModel @AssistedInject constructor(
init {
getListOfUserLiveLocationUseCase.execute(initialState.roomId)
.onEach { setState { copy(userLocations = it) } }
.onEach { setState { copy(userLocations = it, showLocateButton = it.none { it.matrixItem.id == session.myUserId }) } }
.launchIn(viewModelScope)
locationSharingServiceConnection.bind(this)
}

View File

@ -29,6 +29,7 @@ data class LiveLocationMapViewState(
*/
val mapSymbolIds: Map<String, Long> = emptyMap(),
val loadingMapHasFailed: Boolean = false,
val showLocateButton: Boolean = false,
) : MavericksState {
constructor(liveLocationMapViewArgs: LiveLocationMapViewArgs) : this(
roomId = liveLocationMapViewArgs.roomId