mirror of
https://github.com/ente-io/ente.git
synced 2025-08-13 17:57:31 +00:00
Manage fi open/close
This commit is contained in:
@@ -13,10 +13,7 @@ if (process.env.NEXT_PUBLIC_ENTE_WIP_PS5) {
|
|||||||
throw new Error("Whoa");
|
throw new Error("Whoa");
|
||||||
}
|
}
|
||||||
|
|
||||||
import {
|
import { type ModalVisibilityProps } from "@/base/components/utils/modal";
|
||||||
useModalVisibility,
|
|
||||||
type ModalVisibilityProps,
|
|
||||||
} from "@/base/components/utils/modal";
|
|
||||||
import type { LocalUser } from "@/base/local-user";
|
import type { LocalUser } from "@/base/local-user";
|
||||||
import log from "@/base/log";
|
import log from "@/base/log";
|
||||||
import {
|
import {
|
||||||
@@ -127,17 +124,17 @@ const FileViewer: React.FC<FileViewerProps> = ({
|
|||||||
FileInfoExif | undefined
|
FileInfoExif | undefined
|
||||||
>(undefined);
|
>(undefined);
|
||||||
|
|
||||||
|
const [openFileInfo, setOpenFileInfo] = useState(false);
|
||||||
|
|
||||||
// If `true`, then we need to trigger a sync with remote when we close.
|
// If `true`, then we need to trigger a sync with remote when we close.
|
||||||
const [, setNeedsSync] = useState(false);
|
const [, setNeedsSync] = useState(false);
|
||||||
|
|
||||||
const { show: showFileInfo, props: fileInfoVisibilityProps } =
|
|
||||||
useModalVisibility();
|
|
||||||
|
|
||||||
const handleClose = useCallback(() => {
|
const handleClose = useCallback(() => {
|
||||||
setNeedsSync((needSync) => {
|
setNeedsSync((needSync) => {
|
||||||
if (needSync) onTriggerSyncWithRemote?.();
|
if (needSync) onTriggerSyncWithRemote?.();
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
setOpenFileInfo(false);
|
||||||
onClose();
|
onClose();
|
||||||
}, [onTriggerSyncWithRemote, onClose]);
|
}, [onTriggerSyncWithRemote, onClose]);
|
||||||
|
|
||||||
@@ -158,11 +155,13 @@ const FileViewer: React.FC<FileViewerProps> = ({
|
|||||||
setActiveFileExif(exif),
|
setActiveFileExif(exif),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
showFileInfo();
|
setOpenFileInfo(true);
|
||||||
},
|
},
|
||||||
[showFileInfo],
|
[],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const handleInfoClose = useCallback(() => setOpenFileInfo(false), []);
|
||||||
|
|
||||||
const handleScheduleUpdate = useCallback(() => setNeedsSync(true), []);
|
const handleScheduleUpdate = useCallback(() => setNeedsSync(true), []);
|
||||||
|
|
||||||
const handleSelectCollection = useCallback(
|
const handleSelectCollection = useCallback(
|
||||||
@@ -235,7 +234,8 @@ const FileViewer: React.FC<FileViewerProps> = ({
|
|||||||
<Container>
|
<Container>
|
||||||
<Button>Test</Button>
|
<Button>Test</Button>
|
||||||
<FileInfo
|
<FileInfo
|
||||||
{...fileInfoVisibilityProps}
|
open={openFileInfo}
|
||||||
|
onClose={handleInfoClose}
|
||||||
file={activeAnnotatedFile?.file}
|
file={activeAnnotatedFile?.file}
|
||||||
exif={activeFileExif}
|
exif={activeFileExif}
|
||||||
allowEdits={!!activeAnnotatedFile?.annotation.isOwnFile}
|
allowEdits={!!activeAnnotatedFile?.annotation.isOwnFile}
|
||||||
|
Reference in New Issue
Block a user