From 6b25555044efb1b356bce14685232557192431c6 Mon Sep 17 00:00:00 2001 From: abhinav-grd Date: Mon, 11 Oct 2021 10:30:36 +0530 Subject: [PATCH] added fix thumbnail modal --- src/components/FixLargeThumbnail.tsx | 108 +++++++++++++++++++++++++ src/components/Sidebar.tsx | 13 +++ src/utils/strings/englishConstants.tsx | 1 + 3 files changed, 122 insertions(+) create mode 100644 src/components/FixLargeThumbnail.tsx diff --git a/src/components/FixLargeThumbnail.tsx b/src/components/FixLargeThumbnail.tsx new file mode 100644 index 000000000..bb49261a9 --- /dev/null +++ b/src/components/FixLargeThumbnail.tsx @@ -0,0 +1,108 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import constants from 'utils/strings/constants'; +import MessageDialog from './MessageDialog'; +import React, { useContext, useState } from 'react'; +import { ProgressBar, Button } from 'react-bootstrap'; +import { ComfySpan } from './ExportInProgress'; +import { regenerateThumbnail } from 'services/migrate'; +import { GalleryContext } from 'pages/gallery'; +import { RequestCanceller } from 'services/upload/queueProcessor'; +import { getLocalFiles } from 'services/fileService'; + +interface Props { + show: boolean; + hide: () => void; +} + +export default function FixLargeThumbnails(props: Props) { + const galleryContext = useContext(GalleryContext); + const [inprogress, SetInProgress] = useState(true); + const [updateCanceler, setUpdateCanceler] = useState({ + exec: () => null, + }); + const [progressTracker, setProgressTracker] = useState(); + const cancelFix = () => { + updateCanceler.exec(); + SetInProgress(false); + }; + const startFix = async () => { + SetInProgress(true); + const localFiles = await getLocalFiles(); + regenerateThumbnail(localFiles); + }; + return ( + +
+ {inprogress ? ( + <> +
+ + {' '} + {0} / {10}{' '} + {' '} + + {' '} + files exported + +
+
+ +
+ + ) : ( +
+ Your some files have of the thumbnails have been updated + of large size do you want to update them with low res + version to save space +
+ )} +
+ +
+ {inprogress ? ( + + ) : ( + + )} +
+
+ + ); +} diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx index 8e1ac23e3..cf111826f 100644 --- a/src/components/Sidebar.tsx +++ b/src/components/Sidebar.tsx @@ -33,6 +33,7 @@ import exportService from 'services/exportService'; import { Subscription } from 'services/billingService'; import { PAGES } from 'types'; import { ARCHIVE_SECTION } from 'components/pages/gallery/Collections'; +import FixLargeThumbnails from './FixLargeThumbnail'; interface Props { collections: Collection[]; setDialogMessage: SetDialogMessage; @@ -50,6 +51,7 @@ export default function Sidebar(props: Props) { const [recoverModalView, setRecoveryModalView] = useState(false); const [twoFactorModalView, setTwoFactorModalView] = useState(false); const [exportModalView, setExportModalView] = useState(false); + const [fixLargeThumbsView, setFixLargeThumbsView] = useState(true); const galleryContext = useContext(GalleryContext); useEffect(() => { const main = async () => { @@ -267,6 +269,17 @@ export default function Sidebar(props: Props) { {constants.UPDATE_EMAIL} + <> + setFixLargeThumbsView(false)} + /> + setFixLargeThumbsView(true)}> + {constants.FIX_LARGE_THUMBNAILS} + + diff --git a/src/utils/strings/englishConstants.tsx b/src/utils/strings/englishConstants.tsx index 2c849281a..d105b0c74 100644 --- a/src/utils/strings/englishConstants.tsx +++ b/src/utils/strings/englishConstants.tsx @@ -552,6 +552,7 @@ const englishConstants = { SORT_BY_LATEST_PHOTO: 'recent photo', SORT_BY_MODIFICATION_TIME: 'last updated', SORT_BY_COLLECTION_NAME: 'album name', + FIX_LARGE_THUMBNAILS: 'fix large thumbnails', }; export default englishConstants;