Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Sort and use

Manav Rathi897c584438d0
diff --git a/web/apps/photos/src/components/PhotoViewer/FileInfo/index.tsx b/web/apps/photos/src/components/PhotoViewer/FileInfo/index.tsx
index 2f20e168aa..16217ef694 100644
--- a/web/apps/photos/src/components/PhotoViewer/FileInfo/index.tsx
+++ b/web/apps/photos/src/components/PhotoViewer/FileInfo/index.tsx
@@ -3,6 +3,7 @@ import type { MiniDialogAttributes } from "@/base/components/MiniDialog";
import { ActivityIndicator } from "@/base/components/mui/ActivityIndicator";
import { Titlebar } from "@/base/components/Titlebar";
import { EllipsizedTypography } from "@/base/components/Typography";
+import { useModalVisibility } from "@/base/components/utils/modal";
import { nameAndExtension } from "@/base/file";
import log from "@/base/log";
import type { Location } from "@/base/types";
@@ -107,7 +108,8 @@ export const FileInfo: React.FC<FileInfoProps> = ({
);
const [exifInfo, setExifInfo] = useState<ExifInfo | undefined>();
- const [openRawExif, setOpenRawExif] = useState(false);
+ const { show: showRawExif, props: rawExifVisibilityProps } =
+ useModalVisibility();
const [annotatedFaces, setAnnotatedFaces] = useState<
AnnotatedFacesForFile | undefined
>();
@@ -262,7 +264,7 @@ export const FileInfo: React.FC<FileInfoProps> = ({
t("no_exif")
) : (
<LinkButton
- onClick={() => setOpenRawExif(true)}
+ onClick={showRawExif}
sx={{
textDecoration: "none",
color: "text.muted",
@@ -319,8 +321,7 @@ export const FileInfo: React.FC<FileInfoProps> = ({
</Stack>
<RawExif
- open={openRawExif}
- onClose={() => setOpenRawExif(false)}
+ {...rawExifVisibilityProps}
onInfoClose={handleCloseInfo}
tags={exif?.tags}
fileName={file.metadata.title}
diff --git a/web/apps/photos/src/components/PhotoViewer/index.tsx b/web/apps/photos/src/components/PhotoViewer/index.tsx
index cfedb188eb..94063e118a 100644
--- a/web/apps/photos/src/components/PhotoViewer/index.tsx
+++ b/web/apps/photos/src/components/PhotoViewer/index.tsx
@@ -1,27 +1,14 @@
-import log from "@/base/log";
-import { EnteFile } from "@/new/photos/types/file";
-import Photoswipe from "photoswipe";
-import PhotoswipeUIDefault from "photoswipe/dist/photoswipe-ui-default";
-import { useContext, useEffect, useMemo, useRef, useState } from "react";
-import {
- addToFavorites,
- removeFromFavorites,
-} from "services/collectionService";
-import {
- copyFileToClipboard,
- downloadSingleFile,
- getFileFromURL,
-} from "utils/file";
-
import { isDesktop } from "@/base/app";
import { ActivityIndicator } from "@/base/components/mui/ActivityIndicator";
import { lowercaseExtension } from "@/base/file";
+import log from "@/base/log";
import { FileType } from "@/media/file-type";
import { isHEICExtension, needsJPEGConversion } from "@/media/formats";
import downloadManager from "@/new/photos/services/download";
import { extractRawExif, parseExif } from "@/new/photos/services/exif";
import { AppContext } from "@/new/photos/types/context";
import type { LoadedLivePhotoSourceURL } from "@/new/photos/types/file";
+import { EnteFile } from "@/new/photos/types/file";
import { fileLogID } from "@/new/photos/utils/file";
import { FlexWrapper } from "@ente/shared/components/Container";
import AlbumOutlined from "@mui/icons-material/AlbumOutlined";
@@ -43,8 +30,20 @@ import { Box, Button, styled } from "@mui/material";
import { t } from "i18next";
import isElectron from "is-electron";
import { GalleryContext } from "pages/gallery";
+import Photoswipe from "photoswipe";
+import PhotoswipeUIDefault from "photoswipe/dist/photoswipe-ui-default";
+import { useContext, useEffect, useMemo, useRef, useState } from "react";
+import {
+ addToFavorites,
+ removeFromFavorites,
+} from "services/collectionService";
import { trashFiles } from "services/fileService";
import { SetFilesDownloadProgressAttributesCreator } from "types/gallery";
+import {
+ copyFileToClipboard,
+ downloadSingleFile,
+ getFileFromURL,
+} from "utils/file";
import { pauseVideo, playVideo } from "utils/photoFrame";
import { PublicCollectionGalleryContext } from "utils/publicCollectionGallery";
import { getTrashFileMessage } from "utils/ui";
diff --git a/web/apps/photos/src/components/WatchFolder.tsx b/web/apps/photos/src/components/WatchFolder.tsx
index 4b32600322..b2fabae053 100644
--- a/web/apps/photos/src/components/WatchFolder.tsx
+++ b/web/apps/photos/src/components/WatchFolder.tsx
@@ -1,5 +1,8 @@
import { EllipsizedTypography } from "@/base/components/Typography";
-import type { ModalVisibilityProps } from "@/base/components/utils/modal";
+import {
+ useModalVisibility,
+ type ModalVisibilityProps,
+} from "@/base/components/utils/modal";
import { ensureElectron } from "@/base/electron";
import { basename, dirname } from "@/base/file";
import type { CollectionMapping, FolderWatch } from "@/base/types/ipc";
@@ -51,9 +54,8 @@ export const WatchFolder: React.FC<ModalVisibilityProps> = ({
const [savedFolderPath, setSavedFolderPath] = useState<
string | undefined
>();
- // True when we're showing the choice dialog to ask the user to set the
- // collection mapping.
- const [openChoiceDialog, setOpenChoiceDialog] = useState(false);
+ const { show: showMappingChoice, props: mappingChoiceVisibilityProps } =
+ useModalVisibility();
const appContext = useContext(AppContext);
@@ -87,7 +89,7 @@ export const WatchFolder: React.FC<ModalVisibilityProps> = ({
addWatch(path, "root");
} else {
setSavedFolderPath(path);
- setOpenChoiceDialog(true);
+ showMappingChoice();
}
};
@@ -138,8 +140,7 @@ export const WatchFolder: React.FC<ModalVisibilityProps> = ({
</DialogContent>
</Dialog>
<CollectionMappingChoiceDialog
- open={openChoiceDialog}
- onClose={() => setOpenChoiceDialog(false)}
+ {...mappingChoiceVisibilityProps}
didSelect={handleCollectionMappingSelect}
/>
</>