This commit is contained in:
Manav Rathi
2025-06-27 08:20:32 +05:30
parent ae5144635e
commit 7016861281
2 changed files with 26 additions and 2 deletions

View File

@@ -1,4 +1,5 @@
import type { User } from "ente-accounts/services/user";
import { isDevBuild } from "ente-base/env";
import log from "ente-base/log";
import { apiURL } from "ente-base/origins";
import { groupFilesByCollectionID, sortFiles } from "ente-gallery/utils/file";
@@ -7,6 +8,7 @@ import {
addToFavorites,
createUncategorizedCollection,
moveFromCollection,
removeFromCollection2,
removeNonUserFilesFromCollection,
savedUserFavoritesCollection,
} from "ente-new/photos/services/collection";
@@ -40,6 +42,10 @@ export const removeFromCollection = async (
collectionID: number,
toRemoveFiles: EnteFile[],
) => {
// TODO(RE):
if (isDevBuild && process.env.ENTE_WIP_MOVE)
return removeFromCollection2(collectionID, toRemoveFiles);
try {
const user: User = getData("user");
const nonUserFiles = [];

View File

@@ -701,10 +701,28 @@ export const deleteFromTrash = async (fileIDs: number[]) =>
*
* See: [Note: Deleting a collection].
*/
export const removeFromCollection = (
export const removeFromCollection2 = async (
collectionID: number,
files: EnteFile[],
) => {};
) => {
const userID = ensureLocalUser().id;
const [userFiles, nonUserFiles] = splitByPredicate(
files,
(f) => f.ownerID == userID,
);
if (userFiles.length) {
await moveUserFilesToUncategorizedIfSoleCollection(
collectionID,
userFiles,
);
}
if (nonUserFiles.length) {
await removeNonUserFilesFromCollection(
collectionID,
nonUserFiles.map((f) => f.id),
);
}
};
/**
* Move the given user owned files whose only user owned instance is in the