π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Prune
Manav Rathi04395739d54e
diff --git a/web/packages/gallery/services/magic-metadata.ts b/web/packages/gallery/services/magic-metadata.tsindex de0b536fc5..f3c6fe7352 100644--- a/web/packages/gallery/services/magic-metadata.ts+++ b/web/packages/gallery/services/magic-metadata.ts@@ -1,7 +1,6 @@// TODO: Review this file/* eslint-disable @typescript-eslint/prefer-optional-chain *//* eslint-disable @typescript-eslint/no-unnecessary-condition */-import { sharedCryptoWorker } from "ente-base/crypto";import type { Collection } from "ente-media/collection";import { ItemVisibility } from "ente-media/file-metadata";@@ -41,85 +40,3 @@ export function isPinnedCollection(item: Collection) {}return item.magicMetadata.data.order !== 0;}--export async function updateMagicMetadata<T>(- magicMetadataUpdates: T,- originalMagicMetadata?: MagicMetadataCore<T>,- decryptionKey?: string,-): Promise<MagicMetadataCore<T>> {- const cryptoWorker = await sharedCryptoWorker();-- if (!originalMagicMetadata) {- originalMagicMetadata = getNewMagicMetadata<T>();- }-- if (typeof originalMagicMetadata?.data == "string") {- // TODO: When converting this (and other parses of magic metadata) to- // use Zod, remember to use looseObject.- //- // See: [Note: Use looseObject for metadata Zod schemas]- // @ts-expect-error TODO: Need to use zod here.- originalMagicMetadata.data = await cryptoWorker.decryptMetadataJSON(- {- encryptedData: originalMagicMetadata.data,- decryptionHeader: originalMagicMetadata.header,- },- // See: [Note: strict mode migration]- //- // eslint-disable-next-line @typescript-eslint/ban-ts-comment- // @ts-ignore- decryptionKey,- );- }- // copies the existing magic metadata properties of the files and updates the visibility value- // The expected behavior while updating magic metadata is to let the existing property as it is and update/add the property you want- const magicMetadataProps: T = {- ...originalMagicMetadata.data,- ...magicMetadataUpdates,- };-- const nonEmptyMagicMetadataProps =- getNonEmptyMagicMetadataProps(magicMetadataProps);-- const magicMetadata = {- ...originalMagicMetadata,- data: nonEmptyMagicMetadataProps,- // See: [Note: strict mode migration]- //- // eslint-disable-next-line @typescript-eslint/ban-ts-comment- // @ts-ignore- count: Object.keys(nonEmptyMagicMetadataProps).length,- };-- return magicMetadata;-}--export const getNewMagicMetadata = <T>(): MagicMetadataCore<T> => {- return {- version: 1,- // See: [Note: strict mode migration]- //- // eslint-disable-next-line @typescript-eslint/ban-ts-comment- // @ts-ignore- data: null,- // See: [Note: strict mode migration]- //- // eslint-disable-next-line @typescript-eslint/ban-ts-comment- // @ts-ignore- header: null,- count: 0,- };-};--export const getNonEmptyMagicMetadataProps = <T>(magicMetadataProps: T): T => {- return Object.fromEntries(- // 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,- ),- ) as T;-};