Notify elsewhere too
This commit is contained in:
@@ -666,24 +666,28 @@ const Page: React.FC = () => {
|
||||
(op: CollectionOp) => (selectedCollection: Collection) => {
|
||||
void (async () => {
|
||||
showLoadingBar();
|
||||
let notifyOthersFiles = false;
|
||||
try {
|
||||
setOpenCollectionSelector(false);
|
||||
const selectedFiles = getSelectedFiles(
|
||||
selected,
|
||||
filteredFiles,
|
||||
);
|
||||
const processableFiles = selectedFiles.filter(
|
||||
const userFiles = selectedFiles.filter(
|
||||
(f) => f.ownerID == user.id,
|
||||
);
|
||||
const sourceCollectionID = selected.collectionID;
|
||||
if (processableFiles.length > 0) {
|
||||
if (userFiles.length > 0) {
|
||||
await performCollectionOp(
|
||||
op,
|
||||
selectedCollection,
|
||||
processableFiles,
|
||||
userFiles,
|
||||
sourceCollectionID,
|
||||
);
|
||||
}
|
||||
// See: [Note: Add and move of non-user files]
|
||||
notifyOthersFiles =
|
||||
userFiles.length != selectedFiles.length;
|
||||
clearSelection();
|
||||
await remotePull({ silent: true });
|
||||
} catch (e) {
|
||||
@@ -691,6 +695,10 @@ const Page: React.FC = () => {
|
||||
} finally {
|
||||
hideLoadingBar();
|
||||
}
|
||||
|
||||
if (notifyOthersFiles) {
|
||||
showMiniDialog(notifyOthersFilesDialogAttributes());
|
||||
}
|
||||
})();
|
||||
};
|
||||
|
||||
|
||||
@@ -50,26 +50,6 @@ interface SelectedFileOptionsProps {
|
||||
*
|
||||
* This will not be set if we are in the people section, or if we are
|
||||
* showing search results.
|
||||
*
|
||||
* TODO: Need to implement delete-equivalent from shared albums.
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
* - Delete action should not be enabled 3 selected (0 Yours). There should
|
||||
* be separate remove action.
|
||||
*
|
||||
* - On remove, if the file and collection both belong to current user, we
|
||||
* just use move api to existing or uncat collection.
|
||||
*
|
||||
* - Otherwise, we call /collections/v3/remove-files (when collection and
|
||||
* file belong to different users).
|
||||
*
|
||||
* - Album owner can remove files of all other users from their collection.
|
||||
* Particiapant (viewer/collaborator) can only remove files that belong to
|
||||
* them.
|
||||
*
|
||||
* Also note that that user cannot delete files that are not owned by the
|
||||
* user, even if they are in an album owned by the user.
|
||||
*/
|
||||
collectionSummary: CollectionSummary | undefined;
|
||||
/**
|
||||
|
||||
@@ -66,37 +66,50 @@ export const findCollectionCreatingUncategorizedIfNeeded = async (
|
||||
* @param selectedCollection The existing or new collection selected by the
|
||||
* user. This serves as the target of the operation.
|
||||
*
|
||||
* @param selectedFiles The files selected by the user, on which the operation
|
||||
* should be performed.
|
||||
* @param selectedUserFiles The files selected by the user, on which the
|
||||
* operation should be performed. Currently these need to all belong to the
|
||||
* user.
|
||||
*
|
||||
* @param sourceCollectionID In the case of a "move", the operation is always
|
||||
* expected to happen in the context of an existing collection, which serves as
|
||||
* the source collection for the move. In such a case, the caller should provide
|
||||
* this argument, using the collection ID of the collection in which the
|
||||
* selection occurred.
|
||||
*
|
||||
* [Note: Add and move of non-user files]
|
||||
*
|
||||
* Currently, all {@link selectedUserFiles} need to belong to the user. This is
|
||||
* because adds and move cannot be performed on remote across ownership
|
||||
* boundaries directly.
|
||||
*
|
||||
* Enhancement: The mobile client has support for adding and moving such files.
|
||||
* It does so by creating a copy, but using hash checks to avoid a copy if not
|
||||
* needed. Implement these. This is a bit non-trivial since the mobile client
|
||||
* then also adds various heuristics to omit the display of the "doubled" files
|
||||
* in the all section etc.
|
||||
*/
|
||||
export const performCollectionOp = async (
|
||||
op: CollectionOp,
|
||||
selectedCollection: Collection,
|
||||
selectedFiles: EnteFile[],
|
||||
selectedUserFiles: EnteFile[],
|
||||
sourceCollectionID: number | undefined,
|
||||
): Promise<void> => {
|
||||
switch (op) {
|
||||
case "add":
|
||||
await addToCollection(selectedCollection, selectedFiles);
|
||||
await addToCollection(selectedCollection, selectedUserFiles);
|
||||
break;
|
||||
case "move":
|
||||
await moveFromCollection(
|
||||
sourceCollectionID!,
|
||||
selectedCollection,
|
||||
selectedFiles,
|
||||
selectedUserFiles,
|
||||
);
|
||||
break;
|
||||
case "restore":
|
||||
await restoreToCollection(selectedCollection, selectedFiles);
|
||||
await restoreToCollection(selectedCollection, selectedUserFiles);
|
||||
break;
|
||||
case "unhide":
|
||||
await moveToCollection(selectedCollection, selectedFiles);
|
||||
await moveToCollection(selectedCollection, selectedUserFiles);
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
import InfoOutlinedIcon from "@mui/icons-material/InfoOutlined";
|
||||
import { Link } from "@mui/material";
|
||||
import type { MiniDialogAttributes } from "ente-base/components/MiniDialog";
|
||||
import { pt } from "ente-base/i18n";
|
||||
import { t } from "i18next";
|
||||
import { Trans } from "react-i18next";
|
||||
|
||||
export const confirmEnableMapsDialogAttributes = (
|
||||
onConfirm: () => void,
|
||||
): MiniDialogAttributes => ({
|
||||
title: t("enable_maps_confirm"),
|
||||
message: (
|
||||
<Trans
|
||||
i18nKey={"enable_maps_confirm_message"}
|
||||
components={{
|
||||
a: (
|
||||
<Link
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
href="https://www.openstreetmap.org/"
|
||||
/>
|
||||
),
|
||||
}}
|
||||
/>
|
||||
),
|
||||
continue: { text: t("enable"), action: onConfirm },
|
||||
});
|
||||
|
||||
export const confirmDisableMapsDialogAttributes = (
|
||||
onConfirm: () => void,
|
||||
): MiniDialogAttributes => ({
|
||||
title: t("disable_maps_confirm"),
|
||||
message: <Trans i18nKey={"disable_maps_confirm_message"} />,
|
||||
continue: { text: t("disable"), color: "critical", action: onConfirm },
|
||||
});
|
||||
|
||||
/**
|
||||
* Create attributes for a {@link MiniDialog} notifying the user that some of
|
||||
* the files were not processed because they belonged to other users.
|
||||
*/
|
||||
export const notifyOthersFilesDialogAttributes = () => ({
|
||||
// TODO(RE):
|
||||
title: pt("Note"),
|
||||
icon: <InfoOutlinedIcon />,
|
||||
// TODO(RE):
|
||||
message: pt("Files added by other users were not processed"),
|
||||
cancel: t("ok"),
|
||||
});
|
||||
Reference in New Issue
Block a user