This commit is contained in:
Manav Rathi
2025-06-17 15:34:18 +05:30
parent 8b7e630bed
commit 58e2b8ab52
3 changed files with 14 additions and 18 deletions

View File

@@ -5,15 +5,15 @@ import log from "ente-base/log";
import { type Collection, CollectionSubType } from "ente-media/collection";
import { EnteFile } from "ente-media/file";
import {
DEFAULT_HIDDEN_COLLECTION_USER_FACING_NAME,
HIDDEN_ITEMS_SECTION,
addToCollection,
createAlbum,
defaultHiddenCollectionUserFacingName,
findDefaultHiddenCollectionIDs,
HIDDEN_ITEMS_SECTION,
isHiddenCollection,
isIncomingShare,
moveToCollection,
restoreToCollection,
createAlbum,
} from "ente-new/photos/services/collection";
import {
getAllLocalCollections,
@@ -112,13 +112,13 @@ export async function downloadDefaultHiddenCollectionHelper(
);
const setFilesDownloadProgressAttributes =
setFilesDownloadProgressAttributesCreator(
DEFAULT_HIDDEN_COLLECTION_USER_FACING_NAME,
defaultHiddenCollectionUserFacingName,
HIDDEN_ITEMS_SECTION,
true,
);
await downloadCollectionFiles(
DEFAULT_HIDDEN_COLLECTION_USER_FACING_NAME,
defaultHiddenCollectionUserFacingName,
defaultHiddenCollectionFiles,
setFilesDownloadProgressAttributes,
);

View File

@@ -47,6 +47,7 @@ const requestBatchSize = 1000;
const uncategorizedCollectionName = "Uncategorized";
const defaultHiddenCollectionName = ".hidden";
export const defaultHiddenCollectionUserFacingName = "Hidden";
const favoritesCollectionName = "Favorites";
export const ARCHIVE_SECTION = -1;
@@ -55,20 +56,16 @@ export const DUMMY_UNCATEGORIZED_COLLECTION = -3;
export const HIDDEN_ITEMS_SECTION = -4;
export const ALL_SECTION = 0;
export const DEFAULT_HIDDEN_COLLECTION_USER_FACING_NAME = "Hidden";
/**
* Return the "user facing" name of the given collection.
*
* Usually this is the same as the collection name, but it might be a different
* string for special collections like default hidden collections.
*/
export const getCollectionUserFacingName = (collection: Collection) => {
if (isDefaultHiddenCollection(collection)) {
return DEFAULT_HIDDEN_COLLECTION_USER_FACING_NAME;
}
return collection.name;
};
export const collectionUserFacingName = (collection: Collection) =>
isDefaultHiddenCollection(collection)
? defaultHiddenCollectionUserFacingName
: collection.name;
/**
* Create a new album (a collection of type "album") on remote, and return its
@@ -269,7 +266,7 @@ export const getCollectionChanges = async (
* Return a map of the (user-facing) collection name, indexed by collection ID.
*/
export const createCollectionNameByID = (collections: Collection[]) =>
new Map(collections.map((c) => [c.id, getCollectionUserFacingName(c)]));
new Map(collections.map((c) => [c.id, collectionUserFacingName(c)]));
/**
* A CollectionFileItem represents a file in a API request to add, move or

View File

@@ -20,8 +20,8 @@ import { fileLocation, type Metadata } from "ente-media/file-metadata";
import { FileType } from "ente-media/file-type";
import { decodeLivePhoto } from "ente-media/live-photo";
import {
collectionUserFacingName,
createCollectionNameByID,
getCollectionUserFacingName,
} from "ente-new/photos/services/collection";
import { getAllLocalCollections } from "ente-new/photos/services/collections";
import { getAllLocalFiles } from "ente-new/photos/services/files";
@@ -504,7 +504,7 @@ class ExportService {
);
const newCollectionExportName = await safeDirectoryName(
exportFolder,
getCollectionUserFacingName(collection),
collectionUserFacingName(collection),
fs.exists,
);
log.info(
@@ -1271,8 +1271,7 @@ const getRenamedExportedCollections = (
collection.id,
);
const collectionExportName =
getCollectionUserFacingName(collection);
const collectionExportName = collectionUserFacingName(collection);
if (currentExportName === collectionExportName) {
return false;