Fix and write tests
This commit is contained in:
parent
13defbbcc0
commit
f21aeea980
16 changed files with 952 additions and 266 deletions
|
|
@ -123,6 +123,7 @@ class EventItemFactory @Inject constructor(
|
|||
duration = null,
|
||||
),
|
||||
mediaSource = type.source,
|
||||
// TODO We may want to add a thumbnailSource and set it to type.info?.thumbnailSource
|
||||
)
|
||||
is ImageMessageType -> MediaItem.Image(
|
||||
id = currentTimelineItem.uniqueId,
|
||||
|
|
@ -142,7 +143,7 @@ class EventItemFactory @Inject constructor(
|
|||
duration = null,
|
||||
),
|
||||
mediaSource = type.source,
|
||||
thumbnailSource = null,
|
||||
thumbnailSource = type.info?.thumbnailSource,
|
||||
)
|
||||
is StickerMessageType -> MediaItem.Image(
|
||||
id = currentTimelineItem.uniqueId,
|
||||
|
|
@ -162,7 +163,7 @@ class EventItemFactory @Inject constructor(
|
|||
duration = null,
|
||||
),
|
||||
mediaSource = type.source,
|
||||
thumbnailSource = null,
|
||||
thumbnailSource = type.info?.thumbnailSource,
|
||||
)
|
||||
is VideoMessageType -> MediaItem.Video(
|
||||
id = currentTimelineItem.uniqueId,
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
package io.element.android.libraries.mediaviewer.impl.gallery
|
||||
|
||||
import com.squareup.anvil.annotations.ContributesBinding
|
||||
import io.element.android.libraries.architecture.AsyncData
|
||||
import io.element.android.libraries.di.RoomScope
|
||||
import io.element.android.libraries.di.SingleIn
|
||||
|
|
@ -35,6 +36,7 @@ interface MediaGalleryDataSource {
|
|||
}
|
||||
|
||||
@SingleIn(RoomScope::class)
|
||||
@ContributesBinding(RoomScope::class)
|
||||
class TimelineMediaGalleryDataSource @Inject constructor(
|
||||
private val room: MatrixRoom,
|
||||
private val timelineMediaItemsFactory: TimelineMediaItemsFactory,
|
||||
|
|
@ -62,7 +64,9 @@ class TimelineMediaGalleryDataSource @Inject constructor(
|
|||
timeline = it
|
||||
emit(it)
|
||||
},
|
||||
{ groupedMediaItemsFlow.emit(AsyncData.Failure(it)) },
|
||||
{
|
||||
groupedMediaItemsFlow.emit(AsyncData.Failure(it))
|
||||
},
|
||||
)
|
||||
}.flatMapLatest { timeline ->
|
||||
timeline.timelineItems.onEach {
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ import kotlinx.coroutines.launch
|
|||
class MediaGalleryPresenter @AssistedInject constructor(
|
||||
@Assisted private val navigator: MediaGalleryNavigator,
|
||||
private val room: MatrixRoom,
|
||||
private val mediaGalleryDataSource: TimelineMediaGalleryDataSource,
|
||||
private val mediaGalleryDataSource: MediaGalleryDataSource,
|
||||
private val localMediaFactory: LocalMediaFactory,
|
||||
private val mediaLoader: MatrixMediaLoader,
|
||||
private val localMediaActions: LocalMediaActions,
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ fun aMediaItemImage(
|
|||
id: UniqueId = UniqueId("imageId"),
|
||||
eventId: EventId? = null,
|
||||
senderId: UserId? = null,
|
||||
mediaSourceUrl: String = "",
|
||||
): MediaItem.Image {
|
||||
return MediaItem.Image(
|
||||
id = id,
|
||||
|
|
@ -25,7 +26,7 @@ fun aMediaItemImage(
|
|||
mediaInfo = anImageMediaInfo(
|
||||
senderId = senderId,
|
||||
),
|
||||
mediaSource = MediaSource(""),
|
||||
mediaSource = MediaSource(mediaSourceUrl),
|
||||
thumbnailSource = null,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ class MediaViewerDataSource(
|
|||
private val mediaLoader: MatrixMediaLoader,
|
||||
private val localMediaFactory: LocalMediaFactory,
|
||||
) {
|
||||
|
||||
// List of media files that are currently being loaded
|
||||
private val mediaFiles: MutableList<MediaFile> = mutableListOf()
|
||||
|
||||
|
|
@ -145,6 +144,4 @@ class MediaViewerDataSource(
|
|||
localMediaState.value = AsyncData.Failure(it)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -266,7 +266,6 @@ private fun MediaViewerPage(
|
|||
onShowOverlayChange: (Boolean) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
|
||||
val currentShowOverlay by rememberUpdatedState(showOverlay)
|
||||
val currentOnShowOverlayChange by rememberUpdatedState(onShowOverlayChange)
|
||||
val flickState = rememberFlickToDismissState(dismissThresholdRatio = 0.1f, rotateOnDrag = false)
|
||||
|
|
@ -489,7 +488,7 @@ private fun MediaViewerTopBar(
|
|||
) {
|
||||
Icon(
|
||||
imageVector = CompoundIcons.Info(),
|
||||
contentDescription = null,
|
||||
contentDescription = stringResource(id = CommonStrings.a11y_view_details),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue