This commit is contained in:
Manav Rathi
2024-10-19 11:32:28 +05:30
parent 9db7a780e0
commit b974be5c61
8 changed files with 94 additions and 31 deletions

View File

@@ -9,7 +9,10 @@ import {
GalleryItemsSummary,
} from "@/new/photos/components/gallery/ListHeader";
import { SpaceBetweenFlex } from "@/new/photos/components/mui";
import { ALL_SECTION, HIDDEN_ITEMS_SECTION } from "@/new/photos/services/collection";
import {
ALL_SECTION,
HIDDEN_ITEMS_SECTION,
} from "@/new/photos/services/collection";
import type {
CollectionSummary,
CollectionSummaryType,

View File

@@ -3,6 +3,7 @@ import type { LivePhotoSourceURL, SourceURLs } from "@/media/file";
import { EnteFile } from "@/media/file";
import { FileType } from "@/media/file-type";
import type { GalleryBarMode } from "@/new/photos/components/gallery/BarImpl";
import { TRASH_SECTION } from "@/new/photos/services/collection";
import DownloadManager from "@/new/photos/services/download";
import { PHOTOS_PAGES } from "@ente/shared/constants/pages";
import { CustomError } from "@ente/shared/error";
@@ -19,7 +20,6 @@ import {
SelectedState,
SetFilesDownloadProgressAttributesCreator,
} from "types/gallery";
import { TRASH_SECTION } from "utils/collection";
import {
handleSelectCreator,
updateFileMsrcProps,

View File

@@ -9,6 +9,7 @@ import {
LoadingThumbnail,
StaticThumbnail,
} from "@/new/photos/components/PlaceholderThumbnails";
import { TRASH_SECTION } from "@/new/photos/services/collection";
import DownloadManager from "@/new/photos/services/download";
import { Overlay } from "@ente/shared/components/Container";
import { CustomError } from "@ente/shared/error";
@@ -21,7 +22,6 @@ import i18n from "i18next";
import { DeduplicateContext } from "pages/deduplicate";
import { GalleryContext } from "pages/gallery";
import React, { useContext, useEffect, useRef, useState } from "react";
import { TRASH_SECTION } from "utils/collection";
import { shouldShowAvatar } from "utils/file";
import Avatar from "./Avatar";

View File

@@ -1,5 +1,6 @@
import { stashRedirect } from "@/accounts/services/redirect";
import { ActivityIndicator } from "@/base/components/mui/ActivityIndicator";
import { ALL_SECTION } from "@/new/photos/services/collection";
import { getLocalFiles } from "@/new/photos/services/files";
import { AppContext } from "@/new/photos/types/context";
import { VerticallyCentered } from "@ente/shared/components/Container";
@@ -27,7 +28,6 @@ import {
DefaultDeduplicateContext,
} from "types/deduplicate";
import { SelectedState } from "types/gallery";
import { ALL_SECTION } from "utils/collection";
import { constructFileToCollectionMap, getSelectedFiles } from "utils/file";
export const DeduplicateContext = createContext<DeduplicateContextType>(

View File

@@ -11,6 +11,7 @@ import {
GalleryItemsSummary,
} from "@/new/photos/components/gallery/ListHeader";
import { SpaceBetweenFlex } from "@/new/photos/components/mui";
import { ALL_SECTION } from "@/new/photos/services/collection";
import downloadManager from "@/new/photos/services/download";
import { sortFiles } from "@/new/photos/services/files";
import { AppContext } from "@/new/photos/types/context";
@@ -71,11 +72,7 @@ import {
SetFilesDownloadProgressAttributes,
SetFilesDownloadProgressAttributesCreator,
} from "types/gallery";
import {
ALL_SECTION,
downloadCollectionFiles,
isHiddenCollection,
} from "utils/collection";
import { downloadCollectionFiles, isHiddenCollection } from "utils/collection";
import { downloadSelectedFiles, getSelectedFiles } from "utils/file";
import { formatNumber } from "utils/number/format";
import { PublicCollectionGalleryContext } from "utils/publicCollectionGallery";

View File

@@ -140,11 +140,11 @@ export const setDerivativeState = (
hiddenCollections,
);
hiddenCollectionSummaries.set(HIDDEN_ITEMS_SECTION, hiddenItemsSummaries);
// TODO: Move to reducer
const mergedCollectionSummaries = mergeMaps(
collectionSummaries,
sectionSummaries,
);
// TODO: Move to reducer
// setCollectionSummaries(mergeMaps(collectionSummaries, sectionSummaries));
// TODO: Move to reducer
// setHiddenCollectionSummaries(hiddenCollectionSummaries);
@@ -248,7 +248,10 @@ export function getCollectionSummaries(
collectionSummaries.set(collection.id, {
id: collection.id,
name: CollectionSummaryItemName,
// @ts-expect-error TODO Review types
// See: [Note: strict mode migration]
//
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
latestFile: collectionLatestFiles.get(collection.id),
coverFile: collectionCoverFiles.get(collection.id),
fileCount: collectionFilesCount.get(collection.id) ?? 0,
@@ -308,11 +311,17 @@ export const getCollectionCoverFiles = (
if (collection.pubMagicMetadata?.data?.asc) {
coverFiles.set(
collection.id,
// @ts-expect-error TODO Review types
// See: [Note: strict mode migration]
//
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
collectionFiles[collectionFiles.length - 1],
);
} else {
// @ts-expect-error TODO Review types
// See: [Note: strict mode migration]
//
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
coverFiles.set(collection.id, collectionFiles[0]);
}
});
@@ -332,9 +341,15 @@ export function getDummyUncategorizedCollectionSummary(): CollectionSummary {
id: DUMMY_UNCATEGORIZED_COLLECTION,
name: t("section_uncategorized"),
type: "uncategorized",
// @ts-expect-error TODO Review types
// See: [Note: strict mode migration]
//
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
latestFile: null,
// @ts-expect-error TODO Review types
// See: [Note: strict mode migration]
//
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
coverFile: null,
fileCount: 0,
updationTime: 0,
@@ -360,10 +375,16 @@ export function getHiddenItemsSummary(
name: t("hidden_items"),
type: "hiddenItems",
coverFile: hiddenItems?.[0],
// @ts-expect-error TODO Review types
// See: [Note: strict mode migration]
//
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
latestFile: hiddenItems?.[0],
fileCount: hiddenItems?.length,
// @ts-expect-error TODO Review types
// See: [Note: strict mode migration]
//
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
updationTime: hiddenItems?.[0]?.updationTime,
};
}
@@ -397,12 +418,21 @@ export function getArchivedSectionSummary(
id: ARCHIVE_SECTION,
name: t("section_archive"),
type: "archive",
// @ts-expect-error TODO Review types
// See: [Note: strict mode migration]
//
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
coverFile: null,
// @ts-expect-error TODO Review types
// See: [Note: strict mode migration]
//
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
latestFile: archivedFiles?.[0],
fileCount: archivedFiles?.length ?? 0,
// @ts-expect-error TODO Review types
// See: [Note: strict mode migration]
//
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
updationTime: archivedFiles?.[0]?.updationTime,
};
}
@@ -420,10 +450,16 @@ function getAllSectionSummary(
name: t("section_all"),
type: "all",
coverFile: allSectionFiles?.[0],
// @ts-expect-error TODO Review types
// See: [Note: strict mode migration]
//
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
latestFile: allSectionFiles?.[0],
fileCount: allSectionFiles?.length || 0,
// @ts-expect-error TODO Review types
// See: [Note: strict mode migration]
//
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
updationTime: allSectionFiles?.[0]?.updationTime,
};
}
@@ -462,12 +498,21 @@ export function getTrashedCollectionSummary(
id: TRASH_SECTION,
name: t("section_trash"),
type: "trash",
// @ts-expect-error TODO Review types
// See: [Note: strict mode migration]
//
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
coverFile: null,
// @ts-expect-error TODO Review types
// See: [Note: strict mode migration]
//
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
latestFile: trashedFiles?.[0],
fileCount: trashedFiles?.length,
// @ts-expect-error TODO Review types
// See: [Note: strict mode migration]
//
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
updationTime: trashedFiles?.[0]?.updationTime,
};
}

View File

@@ -6,7 +6,10 @@ export const groupFilesBasedOnCollectionID = (files: EnteFile[]) => {
for (const file of files) {
const id = file.collectionID;
if (!result.has(id)) result.set(id, []);
// @ts-expect-error TODO: Review types
// See: [Note: strict mode migration]
//
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
result.get(id).push(file);
}
return result;

View File

@@ -60,7 +60,10 @@ export async function updateMagicMetadata<T>(
originalMagicMetadata.data = await cryptoWorker.decryptMetadataJSON({
encryptedDataB64: originalMagicMetadata.data,
decryptionHeaderB64: originalMagicMetadata.header,
// @ts-expect-error TODO: Need to use zod here.
// See: [Note: strict mode migration]
//
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
keyB64: decryptionKey,
});
}
@@ -77,7 +80,10 @@ export async function updateMagicMetadata<T>(
const magicMetadata = {
...originalMagicMetadata,
data: nonEmptyMagicMetadataProps,
// @ts-expect-error TODO review this file
// See: [Note: strict mode migration]
//
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
count: Object.keys(nonEmptyMagicMetadataProps).length,
};
@@ -87,9 +93,15 @@ export async function updateMagicMetadata<T>(
export const getNewMagicMetadata = <T>(): MagicMetadataCore<T> => {
return {
version: 1,
// @ts-expect-error TODO review this file
// See: [Note: strict mode migration]
//
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
data: null,
// @ts-expect-error TODO review this file
// See: [Note: strict mode migration]
//
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
header: null,
count: 0,
};
@@ -97,7 +109,10 @@ export const getNewMagicMetadata = <T>(): MagicMetadataCore<T> => {
export const getNonEmptyMagicMetadataProps = <T>(magicMetadataProps: T): T => {
return Object.fromEntries(
// @ts-expect-error TODO review this file
// See: [Note: strict mode migration]
//
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
Object.entries(magicMetadataProps).filter(
// eslint-disable-next-line @typescript-eslint/no-unused-vars
([_, v]) => v !== null && v !== undefined,