mirror of
https://github.com/ente-io/ente.git
synced 2025-08-14 10:16:10 +00:00
Upd
This commit is contained in:
@@ -174,11 +174,8 @@ export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({
|
|||||||
|
|
||||||
const handleDelete = useMemo(() => {
|
const handleDelete = useMemo(() => {
|
||||||
return onMarkTempDeleted
|
return onMarkTempDeleted
|
||||||
? async (file: EnteFile) => {
|
? (file: EnteFile) =>
|
||||||
await moveToTrash([file]);
|
moveToTrash([file]).then(() => onMarkTempDeleted?.([file]))
|
||||||
// See: [Note: File viewer update and dispatch]
|
|
||||||
onMarkTempDeleted?.([file]);
|
|
||||||
}
|
|
||||||
: undefined;
|
: undefined;
|
||||||
}, [onMarkTempDeleted]);
|
}, [onMarkTempDeleted]);
|
||||||
|
|
||||||
|
@@ -804,35 +804,19 @@ const Page: React.FC = () => {
|
|||||||
const handleFileViewerFileVisibilityUpdate = useCallback(
|
const handleFileViewerFileVisibilityUpdate = useCallback(
|
||||||
async (file: EnteFile, visibility: ItemVisibility) => {
|
async (file: EnteFile, visibility: ItemVisibility) => {
|
||||||
const fileID = file.id;
|
const fileID = file.id;
|
||||||
dispatch({
|
dispatch({ type: "addPendingVisibilityUpdate", fileID });
|
||||||
type: "markPendingVisibilityUpdate",
|
|
||||||
fileID,
|
|
||||||
mark: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const privateMagicMetadata =
|
const privateMagicMetadata =
|
||||||
await updateRemotePrivateMagicMetadata(file, {
|
await updateRemotePrivateMagicMetadata(file, {
|
||||||
visibility,
|
visibility,
|
||||||
});
|
});
|
||||||
// TODO(AR): Trigger a "lite" sync?
|
|
||||||
|
|
||||||
// The file viewer listens for the next update to files, so keep
|
|
||||||
// this as the first operation on the happy path that can
|
|
||||||
// trigger an update of files.
|
|
||||||
//
|
|
||||||
// See: [Note: File viewer update and dispatch]
|
|
||||||
dispatch({
|
dispatch({
|
||||||
type: "unsyncedPrivateMagicMetadataUpdate",
|
type: "unsyncedPrivateMagicMetadataUpdate",
|
||||||
fileID,
|
fileID,
|
||||||
privateMagicMetadata,
|
privateMagicMetadata,
|
||||||
});
|
});
|
||||||
} finally {
|
} finally {
|
||||||
dispatch({
|
dispatch({ type: "removePendingVisibilityUpdate", fileID });
|
||||||
type: "markPendingVisibilityUpdate",
|
|
||||||
fileID,
|
|
||||||
mark: false,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[],
|
[],
|
||||||
|
@@ -236,16 +236,12 @@ export type FileViewerProps = ModalVisibilityProps & {
|
|||||||
* Called when the given {@link file} should be downloaded.
|
* Called when the given {@link file} should be downloaded.
|
||||||
*
|
*
|
||||||
* If this is not provided then the download action will not be shown.
|
* 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;
|
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 action will not be shown.
|
* If this is not provided then the delete action will not be shown.
|
||||||
*
|
|
||||||
* See also: [Note: File viewer update and dispatch]
|
|
||||||
*/
|
*/
|
||||||
onDelete?: (file: EnteFile) => Promise<void>;
|
onDelete?: (file: EnteFile) => Promise<void>;
|
||||||
/**
|
/**
|
||||||
|
@@ -434,12 +434,8 @@ export type GalleryAction =
|
|||||||
| { type: "clearTempDeleted" }
|
| { type: "clearTempDeleted" }
|
||||||
| { type: "markTempHidden"; files: EnteFile[] }
|
| { type: "markTempHidden"; files: EnteFile[] }
|
||||||
| { type: "clearTempHidden" }
|
| { type: "clearTempHidden" }
|
||||||
| {
|
| { type: "addPendingVisibilityUpdate"; fileID: number }
|
||||||
type: "markPendingVisibilityUpdate";
|
| { type: "removePendingVisibilityUpdate"; fileID: number }
|
||||||
fileID: number;
|
|
||||||
// Passing `true` adds an entry, and `false` clears any existing one.
|
|
||||||
mark: boolean;
|
|
||||||
}
|
|
||||||
| {
|
| {
|
||||||
type: "unsyncedPrivateMagicMetadataUpdate";
|
type: "unsyncedPrivateMagicMetadataUpdate";
|
||||||
fileID: number;
|
fileID: number;
|
||||||
@@ -879,17 +875,21 @@ const galleryReducer: React.Reducer<GalleryState, GalleryAction> = (
|
|||||||
tempHiddenFileIDs: new Set(),
|
tempHiddenFileIDs: new Set(),
|
||||||
});
|
});
|
||||||
|
|
||||||
case "markPendingVisibilityUpdate": {
|
case "addPendingVisibilityUpdate": {
|
||||||
const pendingVisibilityUpdates = new Set(
|
const pendingVisibilityUpdates = new Set(
|
||||||
state.pendingVisibilityUpdates,
|
state.pendingVisibilityUpdates,
|
||||||
);
|
);
|
||||||
if (action.mark) {
|
pendingVisibilityUpdates.add(action.fileID);
|
||||||
pendingVisibilityUpdates.add(action.fileID);
|
// Not using stateByUpdatingFilteredFiles since it does not depend
|
||||||
} else {
|
// on pendingVisibilityUpdates.
|
||||||
pendingVisibilityUpdates.delete(action.fileID);
|
return { ...state, pendingVisibilityUpdates };
|
||||||
}
|
}
|
||||||
// Skipping a call to stateByUpdatingFilteredFiles since it
|
|
||||||
// currently doesn't depend on pendingVisibilityUpdates.
|
case "removePendingVisibilityUpdate": {
|
||||||
|
const pendingVisibilityUpdates = new Set(
|
||||||
|
state.pendingVisibilityUpdates,
|
||||||
|
);
|
||||||
|
pendingVisibilityUpdates.delete(action.fileID);
|
||||||
return { ...state, pendingVisibilityUpdates };
|
return { ...state, pendingVisibilityUpdates };
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -897,17 +897,14 @@ const galleryReducer: React.Reducer<GalleryState, GalleryAction> = (
|
|||||||
const unsyncedPrivateMagicMetadataUpdates = new Map(
|
const unsyncedPrivateMagicMetadataUpdates = new Map(
|
||||||
state.unsyncedPrivateMagicMetadataUpdates,
|
state.unsyncedPrivateMagicMetadataUpdates,
|
||||||
);
|
);
|
||||||
|
|
||||||
unsyncedPrivateMagicMetadataUpdates.set(
|
unsyncedPrivateMagicMetadataUpdates.set(
|
||||||
action.fileID,
|
action.fileID,
|
||||||
action.privateMagicMetadata,
|
action.privateMagicMetadata,
|
||||||
);
|
);
|
||||||
|
|
||||||
const files = deriveNormalOrHiddenFiles(
|
const files = deriveNormalOrHiddenFiles(
|
||||||
state.lastSyncedFiles,
|
state.lastSyncedFiles,
|
||||||
unsyncedPrivateMagicMetadataUpdates,
|
unsyncedPrivateMagicMetadataUpdates,
|
||||||
);
|
);
|
||||||
|
|
||||||
return stateByUpdatingFilteredFiles({
|
return stateByUpdatingFilteredFiles({
|
||||||
...stateForUpdatedFiles(state, files),
|
...stateForUpdatedFiles(state, files),
|
||||||
unsyncedPrivateMagicMetadataUpdates,
|
unsyncedPrivateMagicMetadataUpdates,
|
||||||
|
@@ -32,16 +32,14 @@ import { splitByPredicate } from "@/utils/array";
|
|||||||
*
|
*
|
||||||
* In some other cases, where we know that only specific collection and/or file
|
* In some other cases, where we know that only specific collection and/or file
|
||||||
* state needs to be synced, step 2 ({@link syncCollectionAndFiles}) is
|
* state needs to be synced, step 2 ({@link syncCollectionAndFiles}) is
|
||||||
* performed independently. Examples of such cases are:
|
* performed independently. The only example of such a cases currently is:
|
||||||
*
|
*
|
||||||
* - After deduping files.
|
* - After deduping files.
|
||||||
* - After performing a file operation (e.g. delete, toggle favorite, toggle
|
|
||||||
* archive) within the file viewer.
|
|
||||||
*
|
*
|
||||||
* The full sync is performed in the following cases:
|
* The full sync is performed in the following cases:
|
||||||
*
|
*
|
||||||
* - On the gallery page load for web and desktop
|
* - On the gallery page load (for both web and desktop).
|
||||||
* - Every 5 minutes thereafter (while the gallery page remains in front).
|
* - Every 5 minutes thereafter (while the user is on the gallery page).
|
||||||
* - Each time the desktop app gains focus.
|
* - Each time the desktop app gains focus.
|
||||||
* - When the file viewer is closed after performing some operation.
|
* - When the file viewer is closed after performing some operation.
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user