mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 21:32:34 +00:00
change : Hide UserLocaitonPuck when currentlySharing from this device (and follow the marker instead of the puck)
This commit is contained in:
+10
-2
@@ -200,7 +200,15 @@ import kotlinx.coroutines.launch
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val userLocationState = userLocationStateFactory.create(hasLocationPermission = permissionsState.isAnyGranted)
|
val isCurrentlySharing by liveLocationShareManager.isCurrentlySharing(roomId = joinedRoom.roomId).collectAsState()
|
||||||
|
val hideUserLocationPuck = mode is ShowLocationMode.Live && isCurrentlySharing
|
||||||
|
val userLocationState = if (hideUserLocationPuck) {
|
||||||
|
// When sharing with this device, use the user LocationShareItem as source of data instead of the device.
|
||||||
|
val ownLocationShare by remember { derivedStateOf { updatedLocationShares.find { it.isOwnUser }?.location?.asMapLibreLocation() } }
|
||||||
|
UserLocationState(ownLocationShare)
|
||||||
|
} else {
|
||||||
|
userLocationStateFactory.create(hasLocationPermission = permissionsState.isAnyGranted)
|
||||||
|
}
|
||||||
return ShowLocationState(
|
return ShowLocationState(
|
||||||
customMapStyleUrl = customMapStyleUrl,
|
customMapStyleUrl = customMapStyleUrl,
|
||||||
dialogState = dialogState,
|
dialogState = dialogState,
|
||||||
@@ -210,7 +218,7 @@ import kotlinx.coroutines.launch
|
|||||||
userLocationState = userLocationState,
|
userLocationState = userLocationState,
|
||||||
isLive = mode is ShowLocationMode.Live,
|
isLive = mode is ShowLocationMode.Live,
|
||||||
appName = appName,
|
appName = appName,
|
||||||
hideUserLocationPuck = false,
|
hideUserLocationPuck = hideUserLocationPuck,
|
||||||
eventSink = ::handleEvent,
|
eventSink = ::handleEvent,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
+26
@@ -460,4 +460,30 @@ class ShowLocationPresenterTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `live mode user location state uses own share position when sharing`() = runTest {
|
||||||
|
val ownLiveLocationShare = aLiveLocationShare()
|
||||||
|
val fakeRoom = FakeJoinedRoom(
|
||||||
|
liveLocationSharesFlow = MutableStateFlow(listOf(ownLiveLocationShare))
|
||||||
|
)
|
||||||
|
val manager = FakeActiveLiveLocationShareManager(
|
||||||
|
startShareLambda = { _, _ -> Result.success(Unit) }
|
||||||
|
)
|
||||||
|
manager.startShare(fakeRoom.roomId, 1.hours)
|
||||||
|
|
||||||
|
val presenter = createShowLocationPresenter(
|
||||||
|
mode = ShowLocationMode.Live(senderId = A_USER_ID),
|
||||||
|
joinedRoom = fakeRoom,
|
||||||
|
liveLocationShareManager = manager,
|
||||||
|
)
|
||||||
|
val ownLocation = ownLiveLocationShare.lastLocation?.geoUri?.let(Location::fromGeoUri)
|
||||||
|
presenter.test {
|
||||||
|
skipItems(1)
|
||||||
|
val state = awaitItem()
|
||||||
|
assertThat(state.hideUserLocationPuck).isTrue()
|
||||||
|
val location = requireNotNull(state.userLocationState.location)
|
||||||
|
assertThat(location.position.value.latitude).isEqualTo(ownLocation?.lat)
|
||||||
|
assertThat(location.position.value.longitude).isEqualTo(ownLocation?.lon)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user