Show locate button only when current user is not sharing live location
This commit is contained in:
parent
8eff831382
commit
f676a65544
|
@ -194,7 +194,7 @@ class LiveLocationMapViewFragment :
|
||||||
updateMap(viewState.userLocations)
|
updateMap(viewState.userLocations)
|
||||||
}
|
}
|
||||||
updateUserListBottomSheet(viewState.userLocations)
|
updateUserListBottomSheet(viewState.userLocations)
|
||||||
updateLocateButton(showLocateButton = false)
|
updateLocateButton(showLocateButton = viewState.showLocateButton)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateUserListBottomSheet(userLocations: List<UserLiveLocationViewState>) {
|
private fun updateUserListBottomSheet(userLocations: List<UserLiveLocationViewState>) {
|
||||||
|
|
|
@ -28,10 +28,12 @@ import im.vector.app.features.location.live.tracking.LocationSharingServiceConne
|
||||||
import kotlinx.coroutines.flow.launchIn
|
import kotlinx.coroutines.flow.launchIn
|
||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import org.matrix.android.sdk.api.session.Session
|
||||||
import org.matrix.android.sdk.api.session.room.location.UpdateLiveLocationShareResult
|
import org.matrix.android.sdk.api.session.room.location.UpdateLiveLocationShareResult
|
||||||
|
|
||||||
class LiveLocationMapViewModel @AssistedInject constructor(
|
class LiveLocationMapViewModel @AssistedInject constructor(
|
||||||
@Assisted private val initialState: LiveLocationMapViewState,
|
@Assisted private val initialState: LiveLocationMapViewState,
|
||||||
|
private val session: Session,
|
||||||
getListOfUserLiveLocationUseCase: GetListOfUserLiveLocationUseCase,
|
getListOfUserLiveLocationUseCase: GetListOfUserLiveLocationUseCase,
|
||||||
private val locationSharingServiceConnection: LocationSharingServiceConnection,
|
private val locationSharingServiceConnection: LocationSharingServiceConnection,
|
||||||
private val stopLiveLocationShareUseCase: StopLiveLocationShareUseCase,
|
private val stopLiveLocationShareUseCase: StopLiveLocationShareUseCase,
|
||||||
|
@ -46,7 +48,7 @@ class LiveLocationMapViewModel @AssistedInject constructor(
|
||||||
|
|
||||||
init {
|
init {
|
||||||
getListOfUserLiveLocationUseCase.execute(initialState.roomId)
|
getListOfUserLiveLocationUseCase.execute(initialState.roomId)
|
||||||
.onEach { setState { copy(userLocations = it) } }
|
.onEach { setState { copy(userLocations = it, showLocateButton = it.none { it.matrixItem.id == session.myUserId }) } }
|
||||||
.launchIn(viewModelScope)
|
.launchIn(viewModelScope)
|
||||||
locationSharingServiceConnection.bind(this)
|
locationSharingServiceConnection.bind(this)
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ data class LiveLocationMapViewState(
|
||||||
*/
|
*/
|
||||||
val mapSymbolIds: Map<String, Long> = emptyMap(),
|
val mapSymbolIds: Map<String, Long> = emptyMap(),
|
||||||
val loadingMapHasFailed: Boolean = false,
|
val loadingMapHasFailed: Boolean = false,
|
||||||
|
val showLocateButton: Boolean = false,
|
||||||
) : MavericksState {
|
) : MavericksState {
|
||||||
constructor(liveLocationMapViewArgs: LiveLocationMapViewArgs) : this(
|
constructor(liveLocationMapViewArgs: LiveLocationMapViewArgs) : this(
|
||||||
roomId = liveLocationMapViewArgs.roomId
|
roomId = liveLocationMapViewArgs.roomId
|
||||||
|
|
Loading…
Reference in New Issue