mirror of
https://github.com/ente-io/ente.git
synced 2025-08-13 17:57:31 +00:00
link
This commit is contained in:
@@ -32,6 +32,7 @@ import {
|
|||||||
SelectedState,
|
SelectedState,
|
||||||
SetFilesDownloadProgressAttributesCreator,
|
SetFilesDownloadProgressAttributesCreator,
|
||||||
} from "types/gallery";
|
} from "types/gallery";
|
||||||
|
import { downloadSingleFile } from "utils/file";
|
||||||
import { handleSelectCreator } from "utils/photoFrame";
|
import { handleSelectCreator } from "utils/photoFrame";
|
||||||
import { PhotoList } from "./PhotoList";
|
import { PhotoList } from "./PhotoList";
|
||||||
import PreviewCard from "./pages/gallery/PreviewCard";
|
import PreviewCard from "./pages/gallery/PreviewCard";
|
||||||
@@ -284,6 +285,13 @@ const PhotoFrame = ({
|
|||||||
: undefined;
|
: undefined;
|
||||||
}, [favoriteFileIDs, onMarkUnsyncedFavoriteUpdate]);
|
}, [favoriteFileIDs, onMarkUnsyncedFavoriteUpdate]);
|
||||||
|
|
||||||
|
// TODO(PS): Missing dep!
|
||||||
|
const handleDownload = useCallback((file: EnteFile) => {
|
||||||
|
const setSingleFileDownloadProgress =
|
||||||
|
setFilesDownloadProgressAttributesCreator!(file.metadata.title);
|
||||||
|
void downloadSingleFile(file, setSingleFileDownloadProgress);
|
||||||
|
}, []);
|
||||||
|
|
||||||
const handleDelete = useMemo(() => {
|
const handleDelete = useMemo(() => {
|
||||||
return onMarkTempDeleted
|
return onMarkTempDeleted
|
||||||
? async (file: EnteFile) => {
|
? async (file: EnteFile) => {
|
||||||
@@ -586,6 +594,7 @@ const PhotoFrame = ({
|
|||||||
isInTrashSection={activeCollectionID === TRASH_SECTION}
|
isInTrashSection={activeCollectionID === TRASH_SECTION}
|
||||||
onTriggerSyncWithRemote={handleTriggerSyncWithRemote}
|
onTriggerSyncWithRemote={handleTriggerSyncWithRemote}
|
||||||
onToggleFavorite={handleToggleFavorite}
|
onToggleFavorite={handleToggleFavorite}
|
||||||
|
onDownload={handleDownload}
|
||||||
onDelete={handleDelete}
|
onDelete={handleDelete}
|
||||||
onSaveEditedImageCopy={handleSaveEditedImageCopy}
|
onSaveEditedImageCopy={handleSaveEditedImageCopy}
|
||||||
{...{
|
{...{
|
||||||
|
@@ -133,11 +133,18 @@ export type FileViewerProps = ModalVisibilityProps & {
|
|||||||
* See also: [Note: File viewer update and dispatch]
|
* See also: [Note: File viewer update and dispatch]
|
||||||
*/
|
*/
|
||||||
onToggleFavorite?: (file: EnteFile) => Promise<void>;
|
onToggleFavorite?: (file: EnteFile) => Promise<void>;
|
||||||
|
/**
|
||||||
|
* Called when the given {@link file} should be downloaded.
|
||||||
|
*
|
||||||
|
* If this is not provided then the download action will not be shown.
|
||||||
|
*
|
||||||
|
* See also: [Note: File viewer update and dispatch]
|
||||||
|
*/
|
||||||
|
onDownload?: (file: EnteFile) => void;
|
||||||
/**
|
/**
|
||||||
* Called when the given {@link file} should be deleted.
|
* Called when the given {@link file} should be deleted.
|
||||||
*
|
*
|
||||||
* If this is not provided then the delete button will not be shown
|
* If this is not provided then the delete action will not be shown.
|
||||||
* in the file actions.
|
|
||||||
*
|
*
|
||||||
* See also: [Note: File viewer update and dispatch]
|
* See also: [Note: File viewer update and dispatch]
|
||||||
*/
|
*/
|
||||||
@@ -177,6 +184,7 @@ const FileViewer: React.FC<FileViewerProps> = ({
|
|||||||
allCollectionsNameByID,
|
allCollectionsNameByID,
|
||||||
onTriggerSyncWithRemote,
|
onTriggerSyncWithRemote,
|
||||||
onToggleFavorite,
|
onToggleFavorite,
|
||||||
|
onDownload,
|
||||||
onDelete,
|
onDelete,
|
||||||
onSelectCollection,
|
onSelectCollection,
|
||||||
onSelectPerson,
|
onSelectPerson,
|
||||||
@@ -284,24 +292,14 @@ const FileViewer: React.FC<FileViewerProps> = ({
|
|||||||
|
|
||||||
const handleFileInfoClose = useCallback(() => setOpenFileInfo(false), []);
|
const handleFileInfoClose = useCallback(() => setOpenFileInfo(false), []);
|
||||||
|
|
||||||
// The download action itself - either invoked via the download option is
|
|
||||||
// shown in the more menu, or via `handleDownloadBarAction` (if the
|
|
||||||
// download option is shown in the PhotoSwipe bar).
|
|
||||||
const handleDownload = useCallback(
|
|
||||||
(annotatedFile: FileViewerAnnotatedFile) => {
|
|
||||||
console.log("TODO download", annotatedFile);
|
|
||||||
},
|
|
||||||
[],
|
|
||||||
);
|
|
||||||
|
|
||||||
// Callback invoked when the download action is triggered by activating the
|
// Callback invoked when the download action is triggered by activating the
|
||||||
// download button in the PhotoSwipe bar.
|
// download button in the PhotoSwipe bar.
|
||||||
const handleDownloadBarAction = useCallback(
|
const handleDownloadBarAction = useCallback(
|
||||||
(annotatedFile: FileViewerAnnotatedFile) => {
|
(annotatedFile: FileViewerAnnotatedFile) => {
|
||||||
setActiveAnnotatedFile(annotatedFile);
|
setActiveAnnotatedFile(annotatedFile);
|
||||||
handleDownload(annotatedFile);
|
onDownload!(annotatedFile.file);
|
||||||
},
|
},
|
||||||
[handleDownload],
|
[onDownload],
|
||||||
);
|
);
|
||||||
|
|
||||||
// Callback invoked when the download action is triggered by activating the
|
// Callback invoked when the download action is triggered by activating the
|
||||||
@@ -309,7 +307,8 @@ const FileViewer: React.FC<FileViewerProps> = ({
|
|||||||
//
|
//
|
||||||
// Not memoized since it uses the frequently changing `activeAnnotatedFile`.
|
// Not memoized since it uses the frequently changing `activeAnnotatedFile`.
|
||||||
const handleDownloadMenuAction = () => {
|
const handleDownloadMenuAction = () => {
|
||||||
handleDownload(activeAnnotatedFile!);
|
handleMoreMenuClose();
|
||||||
|
onDownload!(activeAnnotatedFile!.file);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleMore = useCallback(
|
const handleMore = useCallback(
|
||||||
@@ -403,6 +402,7 @@ const FileViewer: React.FC<FileViewerProps> = ({
|
|||||||
|
|
||||||
const showDownload = (() => {
|
const showDownload = (() => {
|
||||||
if (disableDownload) return undefined;
|
if (disableDownload) return undefined;
|
||||||
|
if (!onDownload) return undefined;
|
||||||
if (user) {
|
if (user) {
|
||||||
// Logged in users see the download option in the more menu.
|
// Logged in users see the download option in the more menu.
|
||||||
return "menu";
|
return "menu";
|
||||||
@@ -431,6 +431,7 @@ const FileViewer: React.FC<FileViewerProps> = ({
|
|||||||
disableDownload,
|
disableDownload,
|
||||||
isInTrashSection,
|
isInTrashSection,
|
||||||
isInHiddenSection,
|
isInHiddenSection,
|
||||||
|
onDownload,
|
||||||
handleEditImage,
|
handleEditImage,
|
||||||
handleConfirmDelete,
|
handleConfirmDelete,
|
||||||
],
|
],
|
||||||
|
Reference in New Issue
Block a user