mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-02-16 12:00:03 +03:00
Show locate button only when current user is not sharing live location
This commit is contained in:
parent
8eff831382
commit
f676a65544
3 changed files with 5 additions and 2 deletions
|
@ -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>) {
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue