mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-01 00:46:03 +00:00
Merge branch 'develop' into renovate/maplibre.compose
This commit is contained in:
+17
-5
@@ -217,8 +217,8 @@ class ShareLocationPresenter(
|
||||
val replyMode = messageComposerContext.composerMode as? MessageComposerMode.Reply
|
||||
val inReplyToEventId = replyMode?.eventId
|
||||
val geoUri = event.location.toGeoUri()
|
||||
getTimeline().flatMap {
|
||||
it.sendLocation(
|
||||
withTimeline { timeline ->
|
||||
timeline.sendLocation(
|
||||
body = generateBody(geoUri),
|
||||
geoUri = geoUri,
|
||||
description = null,
|
||||
@@ -237,10 +237,22 @@ class ShareLocationPresenter(
|
||||
)
|
||||
}
|
||||
|
||||
private suspend fun getTimeline(): Result<Timeline> {
|
||||
/**
|
||||
* Invokes [block] with the [Timeline] matching [timelineMode].
|
||||
*
|
||||
* For a thread, a dedicated timeline is created and closed once [block] returns, since such a
|
||||
* timeline owns SDK resources. For the other modes, the live timeline is used, and is not
|
||||
* closed here since it is owned by its room.
|
||||
*/
|
||||
private suspend fun <T> withTimeline(block: suspend (Timeline) -> Result<T>): Result<T> {
|
||||
return when (timelineMode) {
|
||||
is Timeline.Mode.Thread -> room.createTimeline(CreateTimelineParams.Threaded(timelineMode.threadRootId))
|
||||
else -> Result.success(room.liveTimeline)
|
||||
is Timeline.Mode.Thread -> {
|
||||
room.createTimeline(CreateTimelineParams.Threaded(timelineMode.threadRootId))
|
||||
.flatMap { threadedTimeline ->
|
||||
threadedTimeline.use { block(it) }
|
||||
}
|
||||
}
|
||||
else -> block(room.liveTimeline)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,4 +2,5 @@
|
||||
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
|
||||
<string name="screen_share_location_live_location_disclaimer_title">"Το ιστορικό ζωντανής τοποθεσίας σας θα αποθηκευτεί στην αίθουσα και θα είναι ορατό στα μέλη μετά το τέλος της συνεδρίας."</string>
|
||||
<string name="screen_share_location_live_location_duration_picker_title">"Επιλέξτε για πόσο χρονικό διάστημα θα κοινοποιείτε την τρέχουσα τοποθεσία σας."</string>
|
||||
<string name="screen_share_location_live_location_missing_permissions">"Δεν έχετε δικαιώματα για να μοιραστείτε την τρέχουσα τοποθεσία σας σε αυτήν την αίθουσα"</string>
|
||||
</resources>
|
||||
|
||||
+39
@@ -708,6 +708,45 @@ class ShareLocationPresenterTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `ShareStaticLocation in a thread closes the created timeline`() = runTest {
|
||||
val threadedTimeline = FakeTimeline(mode = Timeline.Mode.Thread(A_THREAD_ID)).apply {
|
||||
sendLocationLambda = { _, _, _, _, _, _ -> Result.success(Unit) }
|
||||
}
|
||||
val liveTimeline = FakeTimeline()
|
||||
val joinedRoom = FakeJoinedRoom(
|
||||
liveTimeline = liveTimeline,
|
||||
createTimelineResult = { Result.success(threadedTimeline) },
|
||||
)
|
||||
val shareLocationPresenter = createShareLocationPresenter(
|
||||
joinedRoom = joinedRoom,
|
||||
timelineMode = Timeline.Mode.Thread(A_THREAD_ID),
|
||||
)
|
||||
fakePermissionsPresenter.givenState(
|
||||
aPermissionsState(
|
||||
permissions = PermissionsState.Permissions.AllGranted,
|
||||
shouldShowRationale = false,
|
||||
)
|
||||
)
|
||||
|
||||
shareLocationPresenter.test {
|
||||
val initialState = awaitFirstItem()
|
||||
|
||||
initialState.eventSink(
|
||||
ShareLocationEvent.ShareStaticLocation(
|
||||
location = Location(lat = 3.0, lon = 4.0, accuracy = 5.0f),
|
||||
isPinned = false,
|
||||
)
|
||||
)
|
||||
|
||||
advanceUntilIdle()
|
||||
|
||||
assertThat(threadedTimeline.closeCounter).isEqualTo(1)
|
||||
assertThat(liveTimeline.closeCounter).isEqualTo(0)
|
||||
cancelAndIgnoreRemainingEvents()
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun <T> ReceiveTurbine<T>.awaitFirstItem(): T {
|
||||
skipItems(1)
|
||||
return awaitItem()
|
||||
|
||||
Reference in New Issue
Block a user