Better fix to render all items in the gallery. Should be able to render mixed items.
This commit is contained in:
committed by
Benoit Marty
parent
e282212270
commit
a7e6d8af6e
-2
@@ -812,7 +812,6 @@ class MessagesFlowNode(
|
||||
mode = DateFormatterMode.Full,
|
||||
),
|
||||
initialIndex = galleryItemIndex,
|
||||
isAttachment = false,
|
||||
)
|
||||
val galleryItems = event.content.items.map { galleryItem ->
|
||||
GalleryItemData(
|
||||
@@ -845,7 +844,6 @@ class MessagesFlowNode(
|
||||
mode = DateFormatterMode.Full,
|
||||
),
|
||||
initialIndex = galleryItemIndex,
|
||||
isAttachment = true,
|
||||
)
|
||||
val galleryItems = event.content.attachments.map { attachment ->
|
||||
GalleryItemData(
|
||||
|
||||
-1
@@ -23,7 +23,6 @@ data class GalleryInfo(
|
||||
val dateSent: String?,
|
||||
val dateSentFull: String?,
|
||||
val initialIndex: Int,
|
||||
val isAttachment: Boolean,
|
||||
) : Parcelable
|
||||
|
||||
@Parcelize
|
||||
|
||||
+3
@@ -58,6 +58,9 @@ interface MediaViewerEntryPoint : FeatureEntryPoint {
|
||||
}
|
||||
|
||||
sealed interface MediaViewerMode : Parcelable {
|
||||
@Parcelize
|
||||
data object EventGallery : MediaViewerMode
|
||||
|
||||
@Parcelize
|
||||
data class TimelineImagesAndVideos(val timelineMode: Timeline.Mode) : MediaViewerMode
|
||||
|
||||
|
||||
+2
-4
@@ -85,10 +85,8 @@ class GalleryMediaGalleryDataSource(
|
||||
thumbnailSource = galleryItem.thumbnailSource,
|
||||
)
|
||||
}
|
||||
when (mediaItem) {
|
||||
is MediaItem.Image, is MediaItem.Video -> imageAndVideoItems.add(mediaItem)
|
||||
is MediaItem.Audio, is MediaItem.File, is MediaItem.Voice -> fileItems.add(mediaItem)
|
||||
}
|
||||
// Add all items to imageAndVideoItems (we can have mixed attachments)
|
||||
imageAndVideoItems.add(mediaItem)
|
||||
}
|
||||
|
||||
return GalleryMediaGalleryDataSource(
|
||||
|
||||
+1
@@ -64,6 +64,7 @@ class MediaViewerDataSource(
|
||||
private val galleryMode = when (mode) {
|
||||
is MediaViewerMode.TimelineImagesAndVideos -> MediaGalleryMode.Images
|
||||
is MediaViewerMode.TimelineFilesAndAudios -> MediaGalleryMode.Files
|
||||
MediaViewerMode.EventGallery -> MediaGalleryMode.Images
|
||||
}
|
||||
|
||||
// Map of sourceUrl to local media state
|
||||
|
||||
+5
-6
@@ -116,6 +116,8 @@ class MediaViewerNode(
|
||||
)
|
||||
}
|
||||
Timeline.Mode.Media -> timelineMediaGalleryDataSource
|
||||
// null should not happen, input should be MediaViewerEntryPoint.Params.EventGallery in this case
|
||||
null -> timelineMediaGalleryDataSource
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -129,11 +131,7 @@ class MediaViewerNode(
|
||||
is MediaViewerEntryPoint.Params.Avatar ->
|
||||
MediaViewerEntryPoint.MediaViewerMode.TimelineImagesAndVideos(Timeline.Mode.Media)
|
||||
is MediaViewerEntryPoint.Params.EventGallery ->
|
||||
if (inputs.galleryInfo.isAttachment) {
|
||||
MediaViewerEntryPoint.MediaViewerMode.TimelineFilesAndAudios(Timeline.Mode.Media)
|
||||
} else {
|
||||
MediaViewerEntryPoint.MediaViewerMode.TimelineImagesAndVideos(Timeline.Mode.Media)
|
||||
}
|
||||
MediaViewerEntryPoint.MediaViewerMode.EventGallery
|
||||
is MediaViewerEntryPoint.Params.RoomMedia ->
|
||||
inputs.mode
|
||||
},
|
||||
@@ -167,9 +165,10 @@ class MediaViewerNode(
|
||||
}
|
||||
}
|
||||
|
||||
internal fun MediaViewerEntryPoint.MediaViewerMode.getTimelineMode(): Timeline.Mode {
|
||||
internal fun MediaViewerEntryPoint.MediaViewerMode.getTimelineMode(): Timeline.Mode? {
|
||||
return when (this) {
|
||||
is MediaViewerEntryPoint.MediaViewerMode.TimelineImagesAndVideos -> timelineMode
|
||||
is MediaViewerEntryPoint.MediaViewerMode.TimelineFilesAndAudios -> timelineMode
|
||||
MediaViewerEntryPoint.MediaViewerMode.EventGallery -> null
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -240,6 +240,8 @@ class MediaViewerPresenter(
|
||||
val messageResId = when (inputs.mode) {
|
||||
is MediaViewerEntryPoint.MediaViewerMode.TimelineImagesAndVideos -> R.string.screen_media_details_no_more_media_to_show
|
||||
is MediaViewerEntryPoint.MediaViewerMode.TimelineFilesAndAudios -> R.string.screen_media_details_no_more_files_to_show
|
||||
// Should not happen
|
||||
MediaViewerEntryPoint.MediaViewerMode.EventGallery -> R.string.screen_media_details_no_more_media_to_show
|
||||
}
|
||||
val message = SnackbarMessage(messageResId)
|
||||
snackbarDispatcher.post(message)
|
||||
|
||||
Reference in New Issue
Block a user