Merge pull request #4205 from element-hq/feature/bma/mediaNavigation
Add ability to swipe between media when opened from the timeline.
This commit is contained in:
commit
55399798b6
62 changed files with 1002 additions and 376 deletions
|
|
@ -118,8 +118,9 @@ interface MatrixRoom : Closeable {
|
|||
|
||||
/**
|
||||
* Create a new timeline for the media events of the room.
|
||||
* @param eventId The event to focus on, if any.
|
||||
*/
|
||||
suspend fun mediaTimeline(): Result<Timeline>
|
||||
suspend fun mediaTimeline(eventId: EventId?): Result<Timeline>
|
||||
|
||||
fun destroy()
|
||||
|
||||
|
|
|
|||
|
|
@ -253,11 +253,21 @@ class RustMatrixRoom(
|
|||
}
|
||||
}
|
||||
|
||||
override suspend fun mediaTimeline(): Result<Timeline> = withContext(roomDispatcher) {
|
||||
override suspend fun mediaTimeline(
|
||||
eventId: EventId?,
|
||||
): Result<Timeline> = withContext(roomDispatcher) {
|
||||
val focus = if (eventId != null) {
|
||||
TimelineFocus.Event(
|
||||
eventId = eventId.value,
|
||||
numContextEvents = 50u,
|
||||
)
|
||||
} else {
|
||||
TimelineFocus.Live
|
||||
}
|
||||
runCatching {
|
||||
innerRoom.timelineWithConfiguration(
|
||||
configuration = TimelineConfiguration(
|
||||
focus = TimelineFocus.Live,
|
||||
focus = focus,
|
||||
allowedMessageTypes = AllowedMessageTypes.Only(
|
||||
types = listOf(
|
||||
RoomMessageEventMessageType.FILE,
|
||||
|
|
@ -270,7 +280,7 @@ class RustMatrixRoom(
|
|||
dateDividerMode = DateDividerMode.MONTHLY,
|
||||
)
|
||||
).let { inner ->
|
||||
createTimeline(inner, mode = Timeline.Mode.MEDIA)
|
||||
createTimeline(inner, mode = if (eventId != null) Timeline.Mode.FOCUSED_ON_EVENT else Timeline.Mode.MEDIA)
|
||||
}
|
||||
}.onFailure {
|
||||
if (it is CancellationException) {
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ val A_THREAD_ID = ThreadId("\$aThreadId")
|
|||
val A_THREAD_ID_2 = ThreadId("\$aThreadId2")
|
||||
val AN_EVENT_ID = EventId("\$anEventId")
|
||||
val AN_EVENT_ID_2 = EventId("\$anEventId2")
|
||||
val AN_EVENT_ID_3 = EventId("\$anEventId3")
|
||||
val A_ROOM_ALIAS = RoomAlias("#alias1:domain")
|
||||
val A_TRANSACTION_ID = TransactionId("aTransactionId")
|
||||
val A_DEVICE_ID = DeviceId("ILAKNDNASDLK")
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ class FakeMatrixRoom(
|
|||
private val getMembersResult: (Int) -> Result<List<RoomMember>> = { lambdaError() },
|
||||
private val timelineFocusedOnEventResult: (EventId) -> Result<Timeline> = { lambdaError() },
|
||||
private val pinnedEventsTimelineResult: () -> Result<Timeline> = { lambdaError() },
|
||||
private val mediaTimelineResult: () -> Result<Timeline> = { lambdaError() },
|
||||
private val mediaTimelineResult: (EventId?) -> Result<Timeline> = { lambdaError() },
|
||||
private val setSendQueueEnabledLambda: (Boolean) -> Unit = { _: Boolean -> },
|
||||
private val saveComposerDraftLambda: (ComposerDraft) -> Result<Unit> = { _: ComposerDraft -> Result.success(Unit) },
|
||||
private val loadComposerDraftLambda: () -> Result<ComposerDraft?> = { Result.success<ComposerDraft?>(null) },
|
||||
|
|
@ -215,8 +215,8 @@ class FakeMatrixRoom(
|
|||
pinnedEventsTimelineResult()
|
||||
}
|
||||
|
||||
override suspend fun mediaTimeline(): Result<Timeline> = simulateLongTask {
|
||||
mediaTimelineResult()
|
||||
override suspend fun mediaTimeline(eventId: EventId?): Result<Timeline> = simulateLongTask {
|
||||
mediaTimelineResult(eventId)
|
||||
}
|
||||
|
||||
override suspend fun subscribeToSync() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue