π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[web] Show empty albums also
Manav Rathi9f92787ac613
diff --git a/web/apps/photos/src/services/collectionService.ts b/web/apps/photos/src/services/collectionService.tsindex 80f7f741b4..483719ea8c 100644--- a/web/apps/photos/src/services/collectionService.ts+++ b/web/apps/photos/src/services/collectionService.ts@@ -1069,19 +1069,6 @@ export const getFavCollection = async () => {}};-export const getNonEmptyCollections = (- collections: Collection[],- files: EnteFile[],-) => {- const nonEmptyCollectionsIds = new Set<number>();- for (const file of files) {- nonEmptyCollectionsIds.add(file.collectionID);- }- return collections.filter((collection) =>- nonEmptyCollectionsIds.has(collection.id),- );-};-export function sortCollectionSummaries(collectionSummaries: CollectionSummary[],sortBy: COLLECTION_LIST_SORT_BY,@@ -1141,51 +1128,46 @@ export function getCollectionSummaries() {hasUncategorizedCollection = true;}- if (- collectionFilesCount.get(collection.id) ||- collection.type === CollectionType.uncategorized- ) {- let type: CollectionSummaryType;- if (isIncomingShare(collection, user)) {- if (isIncomingCollabShare(collection, user)) {- type = CollectionSummaryType.incomingShareCollaborator;- } else {- type = CollectionSummaryType.incomingShareViewer;- }- } else if (isOutgoingShare(collection, user)) {- type = CollectionSummaryType.outgoingShare;- } else if (isSharedOnlyViaLink(collection)) {- type = CollectionSummaryType.sharedOnlyViaLink;- } else if (isArchivedCollection(collection)) {- type = CollectionSummaryType.archived;- } else if (isDefaultHiddenCollection(collection)) {- type = CollectionSummaryType.defaultHidden;- } else if (isPinnedCollection(collection)) {- type = CollectionSummaryType.pinned;+ let type: CollectionSummaryType;+ if (isIncomingShare(collection, user)) {+ if (isIncomingCollabShare(collection, user)) {+ type = CollectionSummaryType.incomingShareCollaborator;} else {- type = CollectionSummaryType[collection.type];- }-- let CollectionSummaryItemName: string;- if (type === CollectionSummaryType.uncategorized) {- CollectionSummaryItemName = t("UNCATEGORIZED");- } else if (type === CollectionSummaryType.favorites) {- CollectionSummaryItemName = t("FAVORITES");- } else {- CollectionSummaryItemName = collection.name;+ type = CollectionSummaryType.incomingShareViewer;}+ } else if (isOutgoingShare(collection, user)) {+ type = CollectionSummaryType.outgoingShare;+ } else if (isSharedOnlyViaLink(collection)) {+ type = CollectionSummaryType.sharedOnlyViaLink;+ } else if (isArchivedCollection(collection)) {+ type = CollectionSummaryType.archived;+ } else if (isDefaultHiddenCollection(collection)) {+ type = CollectionSummaryType.defaultHidden;+ } else if (isPinnedCollection(collection)) {+ type = CollectionSummaryType.pinned;+ } else {+ type = CollectionSummaryType[collection.type];+ }- collectionSummaries.set(collection.id, {- id: collection.id,- name: CollectionSummaryItemName,- latestFile: collectionLatestFiles.get(collection.id),- coverFile: collectionCoverFiles.get(collection.id),- fileCount: collectionFilesCount.get(collection.id) ?? 0,- updationTime: collection.updationTime,- type: type,- order: collection.magicMetadata?.data?.order ?? 0,- });+ let CollectionSummaryItemName: string;+ if (type === CollectionSummaryType.uncategorized) {+ CollectionSummaryItemName = t("UNCATEGORIZED");+ } else if (type === CollectionSummaryType.favorites) {+ CollectionSummaryItemName = t("FAVORITES");+ } else {+ CollectionSummaryItemName = collection.name;}++ collectionSummaries.set(collection.id, {+ id: collection.id,+ name: CollectionSummaryItemName,+ latestFile: collectionLatestFiles.get(collection.id),+ coverFile: collectionCoverFiles.get(collection.id),+ fileCount: collectionFilesCount.get(collection.id) ?? 0,+ updationTime: collection.updationTime,+ type: type,+ order: collection.magicMetadata?.data?.order ?? 0,+ });}if (!hasUncategorizedCollection) {collectionSummaries.set(diff --git a/web/apps/photos/src/services/export/index.ts b/web/apps/photos/src/services/export/index.tsindex a130f9f729..5e53b99a18 100644--- a/web/apps/photos/src/services/export/index.ts+++ b/web/apps/photos/src/services/export/index.ts@@ -39,7 +39,6 @@ import {import {constructCollectionNameMap,getCollectionUserFacingName,- getNonEmptyPersonalCollections,} from "utils/collection";import { getPersonalFiles } from "utils/file";import { getAllLocalCollections } from "../collectionService";@@ -354,10 +353,8 @@ class ExportService {collectionIdToOwnerIDMap,);- const nonEmptyPersonalCollections = getNonEmptyPersonalCollections(- collections,- personalFiles,- user,+ const personalCollections = collections.filter(+ (collection) => collection.owner.id === user?.id,);const exportRecord = await this.getExportRecord(exportFolder);@@ -365,12 +362,11 @@ class ExportService {convertCollectionIDExportNameObjectToMap(exportRecord.collectionExportNames,);- const collectionIDNameMap = constructCollectionNameMap(- nonEmptyPersonalCollections,- );+ const collectionIDNameMap =+ constructCollectionNameMap(personalCollections);const renamedCollections = getRenamedExportedCollections(- nonEmptyPersonalCollections,+ personalCollections,exportRecord,);@@ -396,7 +392,7 @@ class ExportService {);const deletedExportedCollections = getDeletedExportedCollections(- nonEmptyPersonalCollections,+ personalCollections,exportRecord,);diff --git a/web/apps/photos/src/services/export/migration.ts b/web/apps/photos/src/services/export/migration.tsindex 2116ca258c..9727bbe883 100644--- a/web/apps/photos/src/services/export/migration.ts+++ b/web/apps/photos/src/services/export/migration.ts@@ -28,7 +28,6 @@ import {ExportedCollectionPaths,FileExportNames,} from "types/export";-import { getNonEmptyPersonalCollections } from "utils/collection";import { getIDBasedSortedFiles, getPersonalFiles } from "utils/file";import {getCollectionIDFromFileUID,@@ -111,13 +110,11 @@ async function migrationV0ToV1(const personalFiles = getIDBasedSortedFiles(getPersonalFiles(localFiles, user),);- const nonEmptyPersonalCollections = getNonEmptyPersonalCollections(- localCollections,- personalFiles,- user,+ const personalCollections = localCollections.filter(+ (collection) => collection.owner.id === user?.id,);await migrateCollectionFolders(- nonEmptyPersonalCollections,+ personalCollections,exportDir,collectionIDPathMap,);diff --git a/web/apps/photos/src/utils/collection.ts b/web/apps/photos/src/utils/collection.tsindex 084bbc97ea..a85e36e677 100644--- a/web/apps/photos/src/utils/collection.ts+++ b/web/apps/photos/src/utils/collection.ts@@ -23,7 +23,6 @@ import {createAlbum,getAllLocalCollections,getLocalCollections,- getNonEmptyCollections,moveToCollection,removeFromCollection,restoreToCollection,@@ -546,24 +545,6 @@ export function getCollectionNameMap();}-export function getNonEmptyPersonalCollections(- collections: Collection[],- personalFiles: EnteFile[],- user: User,-): Collection[] {- if (!user?.id) {- throw Error("user missing");- }- const nonEmptyCollections = getNonEmptyCollections(- collections,- personalFiles,- );- const personalCollections = nonEmptyCollections.filter(- (collection) => collection.owner.id === user?.id,- );- return personalCollections;-}-export function getNonHiddenCollections(collections: Collection[],): Collection[] {diff --git a/web/apps/photos/tests/upload.test.ts b/web/apps/photos/tests/upload.test.tsindex faa485d383..7dd604b0ae 100644--- a/web/apps/photos/tests/upload.test.ts+++ b/web/apps/photos/tests/upload.test.ts@@ -140,19 +140,12 @@ async function totalFileCountCheck(expectedState) {async function totalCollectionCountCheck(expectedState) {const collections = await getLocalCollections();- const files = await getLocalFiles();- const nonEmptyCollectionIds = new Set(- files.map((file) => file.collectionID),- );- const nonEmptyCollections = collections.filter((collection) =>- nonEmptyCollectionIds.has(collection.id),- );- if (expectedState["collection_count"] === nonEmptyCollections.length) {+ if (expectedState["collection_count"] === collections.length) {console.log("collection count check passed β ");} else {throw Error(`total Collection count check failed β- expected : ${expectedState["collection_count"]}, got: ${nonEmptyCollections.length}`,+ expected : ${expectedState["collection_count"]}, got: ${collections.length}`,);}}