diff --git a/ui/src/components/photoGallery/PhotoGallery.tsx b/ui/src/components/photoGallery/PhotoGallery.tsx index c68df314..054284e2 100644 --- a/ui/src/components/photoGallery/PhotoGallery.tsx +++ b/ui/src/components/photoGallery/PhotoGallery.tsx @@ -30,7 +30,7 @@ const Gallery = styled.div` } ` -const PhotoFiller = styled.div` +export const PhotoFiller = styled.div` height: 200px; flex-grow: 999999; ` diff --git a/ui/src/components/timelineGallery/TimelineGroupAlbum.tsx b/ui/src/components/timelineGallery/TimelineGroupAlbum.tsx index 3bbf6f32..dbc0b838 100644 --- a/ui/src/components/timelineGallery/TimelineGroupAlbum.tsx +++ b/ui/src/components/timelineGallery/TimelineGroupAlbum.tsx @@ -1,6 +1,7 @@ import React from 'react' import { Link } from 'react-router-dom' import { MediaThumbnail } from '../photoGallery/MediaThumbnail' +import { PhotoFiller } from '../photoGallery/PhotoGallery' import { toggleFavoriteAction, useMarkFavoriteMutation, @@ -72,9 +73,9 @@ const TimelineGroupAlbum = ({ {albumTitle} -
+
{mediaElms} - {/* {itemsBubble} */} +
) diff --git a/ui/src/components/timelineGallery/timelineGalleryReducer.test.ts b/ui/src/components/timelineGallery/timelineGalleryReducer.test.ts index b8a12936..620db4d6 100644 --- a/ui/src/components/timelineGallery/timelineGalleryReducer.test.ts +++ b/ui/src/components/timelineGallery/timelineGalleryReducer.test.ts @@ -144,102 +144,171 @@ describe('timeline gallery reducer', () => { media: -1, }, timelineGroups: [ - // { - // date: '2020-12-13T00:00:00Z', - // albums: [ - // { - // id: '522', - // title: 'random', - // media: [ - // { - // __typename: 'Media', - // id: '1058', - // title: '122A2876.jpg', - // type: MediaType.Photo, - // thumbnail: { - // __typename: 'MediaURL', - // url: 'http://localhost:4001/photo/thumbnail_122A2876_jpg_Kp1U80vD.jpg', - // width: 1024, - // height: 682, - // }, - // highRes: { - // __typename: 'MediaURL', - // url: 'http://localhost:4001/photo/122A2876_5cSPMiKL.jpg', - // width: 6720, - // height: 4480, - // }, - // videoWeb: null, - // favorite: false, - // album: { __typename: 'Album', id: '522', title: 'random' }, - // date: '2020-12-13T18:03:40Z', - // }, - // ], - // }, - // ], - // }, - // { - // date: '2020-11-25T00:00:00Z', - // albums: [ - // { - // id: '523', - // title: 'another_album', - // media: [ - // { - // __typename: 'Media', - // id: '1059', - // title: '122A2630-Edit.jpg', - // type: MediaType.Photo, - // thumbnail: { - // __typename: 'MediaURL', - // url: 'http://localhost:4001/photo/thumbnail_122A2630-Edit_jpg_pwjtMkpy.jpg', - // width: 1024, - // height: 682, - // }, - // highRes: { - // __typename: 'MediaURL', - // url: 'http://localhost:4001/photo/122A2630-Edit_ySQWFAgE.jpg', - // width: 6177, - // height: 4118, - // }, - // videoWeb: null, - // favorite: false, - // album: { - // __typename: 'Album', - // id: '523', - // title: 'another_album', - // }, - // date: '2020-11-25T16:14:33Z', - // }, - // { - // __typename: 'Media', - // id: '1060', - // title: '122A2785-2.jpg', - // type: MediaType.Photo, - // thumbnail: { - // __typename: 'MediaURL', - // url: 'http://localhost:4001/photo/thumbnail_122A2785-2_jpg_CevmxEXf.jpg', - // width: 1024, - // height: 1024, - // }, - // highRes: { - // __typename: 'MediaURL', - // url: 'http://localhost:4001/photo/122A2785-2_mCnWjLdb.jpg', - // width: 884, - // height: 884, - // }, - // videoWeb: null, - // favorite: false, - // album: { - // __typename: 'Album', - // id: '523', - // title: 'another_album', - // }, - // date: '2020-11-25T16:43:59Z', - // }, - // ], - // }, - // ], - // }, + { + date: '2020-12-13T00:00:00Z', + albums: [ + { + id: '522', + media: [ + { + __typename: 'Media', + album: { + __typename: 'Album', + id: '522', + title: 'random', + }, + date: '2020-12-13T18:03:40Z', + favorite: false, + highRes: { + __typename: 'MediaURL', + height: 4480, + url: 'http://localhost:4001/photo/122A2876_5cSPMiKL.jpg', + width: 6720, + }, + id: '1058', + thumbnail: { + __typename: 'MediaURL', + height: 682, + url: 'http://localhost:4001/photo/thumbnail_122A2876_jpg_Kp1U80vD.jpg', + width: 1024, + }, + title: '122A2876.jpg', + type: 'Photo', + videoWeb: null, + }, + ], + title: 'random', + }, + ], + }, + { + date: '2020-11-25T00:00:00Z', + albums: [ + { + id: '523', + title: 'another_album', + media: [ + { + __typename: 'Media', + album: { + __typename: 'Album', + id: '523', + title: 'another_album', + }, + date: '2020-11-25T16:14:33Z', + favorite: false, + highRes: { + __typename: 'MediaURL', + height: 4118, + url: 'http://localhost:4001/photo/122A2630-Edit_ySQWFAgE.jpg', + width: 6177, + }, + id: '1059', + thumbnail: { + __typename: 'MediaURL', + height: 682, + url: 'http://localhost:4001/photo/thumbnail_122A2630-Edit_jpg_pwjtMkpy.jpg', + width: 1024, + }, + title: '122A2630-Edit.jpg', + type: 'Photo', + videoWeb: null, + }, + { + __typename: 'Media', + album: { + __typename: 'Album', + id: '523', + title: 'another_album', + }, + date: '2020-11-25T16:43:59Z', + favorite: false, + highRes: { + __typename: 'MediaURL', + height: 884, + url: 'http://localhost:4001/photo/122A2785-2_mCnWjLdb.jpg', + width: 884, + }, + id: '1060', + thumbnail: { + __typename: 'MediaURL', + height: 1024, + url: 'http://localhost:4001/photo/thumbnail_122A2785-2_jpg_CevmxEXf.jpg', + width: 1024, + }, + title: '122A2785-2.jpg', + type: 'Photo', + videoWeb: null, + }, + ], + }, + { + id: '522', + title: 'random', + media: [ + { + __typename: 'Media', + album: { + __typename: 'Album', + id: '522', + title: 'random', + }, + date: '2020-11-25T16:14:33Z', + favorite: false, + highRes: { + __typename: 'MediaURL', + height: 4118, + url: 'http://localhost:4001/photo/122A2630-Edit_em9g89qg.jpg', + width: 6177, + }, + id: '1056', + thumbnail: { + __typename: 'MediaURL', + height: 682, + url: 'http://localhost:4001/photo/thumbnail_122A2630-Edit_jpg_aJPCSDDl.jpg', + width: 1024, + }, + title: '122A2630-Edit.jpg', + type: 'Photo', + videoWeb: null, + }, + ], + }, + ], + }, + { + date: '2020-11-09T00:00:00Z', + albums: [ + { + id: '522', + title: 'random', + media: [ + { + __typename: 'Media', + id: '1054', + title: '122A2559.jpg', + type: MediaType.Photo, + thumbnail: { + __typename: 'MediaURL', + url: 'http://localhost:4001/photo/thumbnail_122A2559_jpg_MsOJtPi8.jpg', + width: 1024, + height: 712, + }, + highRes: { + __typename: 'MediaURL', + url: 'http://localhost:4001/photo/122A2559_FDsQHuBN.jpg', + width: 6246, + height: 4346, + }, + videoWeb: null, + favorite: false, + album: { __typename: 'Album', id: '522', title: 'random' }, + date: '2020-11-09T15:38:09Z', + }, + ], + }, + ], + }, ], }) }) @@ -291,20 +360,20 @@ describe('timeline gallery reducer', () => { media: 0, }, out: { - date: 0, + date: 1, album: 0, - media: 1, + media: 0, }, }, { name: 'next album', in: { - date: 0, + date: 1, album: 0, media: 1, }, out: { - date: 0, + date: 1, album: 1, media: 0, }, @@ -312,12 +381,12 @@ describe('timeline gallery reducer', () => { { name: 'next date', in: { - date: 0, + date: 1, album: 1, - media: 1, + media: 0, }, out: { - date: 1, + date: 2, album: 0, media: 0, }, @@ -325,12 +394,12 @@ describe('timeline gallery reducer', () => { { name: 'reached end', in: { - date: 1, + date: 2, album: 0, media: 0, }, out: { - date: 1, + date: 2, album: 0, media: 0, }, @@ -390,12 +459,12 @@ describe('timeline gallery reducer', () => { { name: 'previous album', in: { - date: 0, + date: 1, album: 1, media: 0, }, out: { - date: 0, + date: 1, album: 0, media: 1, }, @@ -403,12 +472,12 @@ describe('timeline gallery reducer', () => { { name: 'previous date', in: { - date: 1, + date: 2, album: 0, media: 0, }, out: { - date: 0, + date: 1, album: 1, media: 0, }, diff --git a/ui/src/components/timelineGallery/timelineGalleryReducer.tsx b/ui/src/components/timelineGallery/timelineGalleryReducer.tsx index 11344dd5..791f5f2d 100644 --- a/ui/src/components/timelineGallery/timelineGalleryReducer.tsx +++ b/ui/src/components/timelineGallery/timelineGalleryReducer.tsx @@ -2,6 +2,7 @@ import React from 'react' import { myTimeline_myTimeline } from './__generated__/myTimeline' import { TimelineGroup, TimelineGroupAlbum } from './TimelineGallery' import { GalleryAction } from '../photoGallery/photoGalleryReducer' +import { isNil } from '../../helpers/utils' export interface TimelineMediaIndex { date: number @@ -245,6 +246,15 @@ function convertMediaToTimelineGroups( nextAlbum.media.push(media) } + if (!isNil(nextAlbum)) { + albums.push(nextAlbum) + + timelineGroups.push({ + date: albums[0].media[0].date.replace(/\d{2}:\d{2}:\d{2}/, '00:00:00'), + albums: albums, + }) + } + return timelineGroups }