浏览代码

Remove more dead code from cast

Manav Rathi 1 年之前
父节点
当前提交
ded151241f

+ 95 - 0
web/apps/cast/src/components/PhotoAuditorium.tsx

@@ -0,0 +1,95 @@
+import { SlideshowContext } from "pages/slideshow";
+import { useContext, useEffect, useState } from "react";
+
+export default function PhotoAuditorium({
+    url,
+    nextSlideUrl,
+}: {
+    url: string;
+    nextSlideUrl: string;
+}) {
+    const { showNextSlide } = useContext(SlideshowContext);
+
+    const [showPreloadedNextSlide, setShowPreloadedNextSlide] = useState(false);
+    const [nextSlidePrerendered, setNextSlidePrerendered] = useState(false);
+    const [prerenderTime, setPrerenderTime] = useState<number | null>(null);
+
+    useEffect(() => {
+        let timeout: NodeJS.Timeout;
+        let timeout2: NodeJS.Timeout;
+
+        if (nextSlidePrerendered) {
+            const elapsedTime = prerenderTime ? Date.now() - prerenderTime : 0;
+            const delayTime = Math.max(10000 - elapsedTime, 0);
+
+            if (elapsedTime >= 10000) {
+                setShowPreloadedNextSlide(true);
+            } else {
+                timeout = setTimeout(() => {
+                    setShowPreloadedNextSlide(true);
+                }, delayTime);
+            }
+
+            if (showNextSlide) {
+                timeout2 = setTimeout(() => {
+                    showNextSlide();
+                    setNextSlidePrerendered(false);
+                    setPrerenderTime(null);
+                    setShowPreloadedNextSlide(false);
+                }, delayTime);
+            }
+        }
+
+        return () => {
+            if (timeout) clearTimeout(timeout);
+            if (timeout2) clearTimeout(timeout2);
+        };
+    }, [nextSlidePrerendered, showNextSlide, prerenderTime]);
+
+    return (
+        <div
+            style={{
+                width: "100vw",
+                height: "100vh",
+                backgroundImage: `url(${url})`,
+                backgroundSize: "cover",
+                backgroundPosition: "center",
+                backgroundRepeat: "no-repeat",
+                backgroundBlendMode: "multiply",
+                backgroundColor: "rgba(0, 0, 0, 0.5)",
+            }}
+        >
+            <div
+                style={{
+                    height: "100%",
+                    width: "100%",
+                    display: "flex",
+                    justifyContent: "center",
+                    alignItems: "center",
+                    backdropFilter: "blur(10px)",
+                }}
+            >
+                <img
+                    src={url}
+                    style={{
+                        maxWidth: "100%",
+                        maxHeight: "100%",
+                        display: showPreloadedNextSlide ? "none" : "block",
+                    }}
+                />
+                <img
+                    src={nextSlideUrl}
+                    style={{
+                        maxWidth: "100%",
+                        maxHeight: "100%",
+                        display: showPreloadedNextSlide ? "block" : "none",
+                    }}
+                    onLoad={() => {
+                        setNextSlidePrerendered(true);
+                        setPrerenderTime(Date.now());
+                    }}
+                />
+            </div>
+        </div>
+    );
+}

+ 0 - 30
web/apps/cast/src/components/TimerBar.tsx

@@ -1,30 +0,0 @@
-import { useEffect, useState } from "react";
-
-export default function TimerBar({ percentage }: { percentage: number }) {
-    const okColor = "#75C157";
-    const warningColor = "#FFC000";
-    const lateColor = "#FF0000";
-
-    const [backgroundColor, setBackgroundColor] = useState(okColor);
-
-    useEffect(() => {
-        if (percentage >= 40) {
-            setBackgroundColor(okColor);
-        } else if (percentage >= 20) {
-            setBackgroundColor(warningColor);
-        } else {
-            setBackgroundColor(lateColor);
-        }
-    }, [percentage]);
-
-    return (
-        <div
-            style={{
-                width: `${percentage}%`, // Set the width based on the time left
-                height: "10px", // Same as the border thickness
-                backgroundColor, // The color of the moving border
-                transition: "width 1s linear", // Smooth transition for the width change
-            }}
-        />
-    );
-}

+ 0 - 56
web/apps/cast/src/constants/apps.ts

@@ -1,56 +0,0 @@
-import { getAlbumsURL } from "@ente/shared/network/api";
-import { runningInBrowser } from "@ente/shared/platform";
-import { PAGES } from "constants/pages";
-
-export enum APPS {
-    PHOTOS = "PHOTOS",
-    AUTH = "AUTH",
-    ALBUMS = "ALBUMS",
-}
-
-export const ALLOWED_APP_PAGES = new Map([
-    [APPS.ALBUMS, [PAGES.SHARED_ALBUMS, PAGES.ROOT]],
-    [
-        APPS.AUTH,
-        [
-            PAGES.ROOT,
-            PAGES.LOGIN,
-            PAGES.SIGNUP,
-            PAGES.VERIFY,
-            PAGES.CREDENTIALS,
-            PAGES.RECOVER,
-            PAGES.CHANGE_PASSWORD,
-            PAGES.GENERATE,
-            PAGES.AUTH,
-            PAGES.TWO_FACTOR_VERIFY,
-            PAGES.TWO_FACTOR_RECOVER,
-        ],
-    ],
-]);
-
-export const CLIENT_PACKAGE_NAMES = new Map([
-    [APPS.ALBUMS, "io.ente.albums.web"],
-    [APPS.PHOTOS, "io.ente.photos.web"],
-    [APPS.AUTH, "io.ente.auth.web"],
-]);
-
-export const getAppNameAndTitle = () => {
-    if (!runningInBrowser()) {
-        return {};
-    }
-    const currentURL = new URL(window.location.href);
-    const albumsURL = new URL(getAlbumsURL());
-    if (currentURL.origin === albumsURL.origin) {
-        return { name: APPS.ALBUMS, title: "ente Photos" };
-    } else {
-        return { name: APPS.PHOTOS, title: "ente Photos" };
-    }
-};
-
-export const getAppTitle = () => {
-    return getAppNameAndTitle().title;
-};
-
-export const getAppName = () => {
-    return getAppNameAndTitle().name;
-};

+ 0 - 5
web/apps/cast/src/constants/cache.ts

@@ -1,5 +0,0 @@
-export enum CACHES {
-    THUMBS = "thumbs",
-    FACE_CROPS = "face-crops",
-    FILES = "files",
-}

+ 0 - 15
web/apps/cast/src/constants/gallery.ts

@@ -1,15 +0,0 @@
-export const GAP_BTW_TILES = 4;
-export const DATE_CONTAINER_HEIGHT = 48;
-export const SIZE_AND_COUNT_CONTAINER_HEIGHT = 72;
-export const IMAGE_CONTAINER_MAX_HEIGHT = 180;
-export const IMAGE_CONTAINER_MAX_WIDTH = 180;
-export const MIN_COLUMNS = 4;
-export const SPACE_BTW_DATES = 44;
-export const SPACE_BTW_DATES_TO_IMAGE_CONTAINER_WIDTH_RATIO = 0.244;
-
-export enum PLAN_PERIOD {
-    MONTH = "month",
-    YEAR = "year",
-}
-
-export const SYNC_INTERVAL_IN_MICROSECONDS = 1000 * 60 * 5; // 5 minutes

+ 0 - 20
web/apps/cast/src/constants/pages.ts

@@ -1,20 +0,0 @@
-export enum PAGES {
-    CHANGE_EMAIL = "/change-email",
-    CHANGE_PASSWORD = "/change-password",
-    CREDENTIALS = "/credentials",
-    GALLERY = "/gallery",
-    GENERATE = "/generate",
-    LOGIN = "/login",
-    RECOVER = "/recover",
-    SIGNUP = "/signup",
-    TWO_FACTOR_SETUP = "/two-factor/setup",
-    TWO_FACTOR_VERIFY = "/two-factor/verify",
-    TWO_FACTOR_RECOVER = "/two-factor/recover",
-    VERIFY = "/verify",
-    ROOT = "/",
-    SHARED_ALBUMS = "/shared-albums",
-    // ML_DEBUG = '/ml-debug',
-    DEDUPLICATE = "/deduplicate",
-    // AUTH page is used to show (auth)enticator codes
-    AUTH = "/auth",
-}

+ 1 - 88
web/apps/cast/src/constants/upload.ts

@@ -1,6 +1,5 @@
-import { ENCRYPTION_CHUNK_SIZE } from "@ente/shared/crypto/constants";
 import { FILE_TYPE } from "constants/file";
-import { FileTypeInfo, ImportSuggestion } from "types/upload";
+import { FileTypeInfo } from "types/upload";
 
 // list of format that were missed by type-detection for some files.
 export const WHITELISTED_FILE_FORMATS: FileTypeInfo[] = [
@@ -40,89 +39,3 @@ export const WHITELISTED_FILE_FORMATS: FileTypeInfo[] = [
 ];
 
 export const KNOWN_NON_MEDIA_FORMATS = ["xmp", "html", "txt"];
-
-export const EXIFLESS_FORMATS = ["gif", "bmp"];
-
-// this is the chunk size of the un-encrypted file which is read and encrypted before uploading it as a single part.
-export const MULTIPART_PART_SIZE = 20 * 1024 * 1024;
-
-export const FILE_READER_CHUNK_SIZE = ENCRYPTION_CHUNK_SIZE;
-
-export const FILE_CHUNKS_COMBINED_FOR_A_UPLOAD_PART = Math.floor(
-    MULTIPART_PART_SIZE / FILE_READER_CHUNK_SIZE,
-);
-
-export const RANDOM_PERCENTAGE_PROGRESS_FOR_PUT = () => 90 + 10 * Math.random();
-
-export enum UPLOAD_STAGES {
-    START,
-    READING_GOOGLE_METADATA_FILES,
-    EXTRACTING_METADATA,
-    UPLOADING,
-    CANCELLING,
-    FINISH,
-}
-
-export enum UPLOAD_STRATEGY {
-    SINGLE_COLLECTION,
-    COLLECTION_PER_FOLDER,
-}
-
-export enum UPLOAD_RESULT {
-    FAILED,
-    ALREADY_UPLOADED,
-    UNSUPPORTED,
-    BLOCKED,
-    TOO_LARGE,
-    LARGER_THAN_AVAILABLE_STORAGE,
-    UPLOADED,
-    UPLOADED_WITH_STATIC_THUMBNAIL,
-    ADDED_SYMLINK,
-}
-
-export enum PICKED_UPLOAD_TYPE {
-    FILES = "files",
-    FOLDERS = "folders",
-    ZIPS = "zips",
-}
-
-export const MAX_FILE_SIZE_SUPPORTED = 4 * 1024 * 1024 * 1024; // 4 GB
-
-export const LIVE_PHOTO_ASSET_SIZE_LIMIT = 20 * 1024 * 1024; // 20MB
-
-export const A_SEC_IN_MICROSECONDS = 1e6;
-
-export const DEFAULT_IMPORT_SUGGESTION: ImportSuggestion = {
-    rootFolderName: "",
-    hasNestedFolders: false,
-    hasRootLevelFileWithFolder: false,
-};
-
-export const BLACK_THUMBNAIL_BASE64 =
-    "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAEBAQEBAQEB" +
-    "AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/2wBDAQEBAQEBAQ" +
-    "EBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/wAARC" +
-    "ACWASwDAREAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUF" +
-    "BAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk" +
-    "6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztL" +
-    "W2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAA" +
-    "AAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVY" +
-    "nLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImK" +
-    "kpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oAD" +
-    "AMBAAIRAxEAPwD/AD/6ACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKA" +
-    "CgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACg" +
-    "AoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKAC" +
-    "gAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAo" +
-    "AKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACg" +
-    "AoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACg" +
-    "AoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKA" +
-    "CgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKA" +
-    "CgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoA" +
-    "KACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACg" +
-    "AoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAo" +
-    "AKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKA" +
-    "CgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAK" +
-    "ACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoA" +
-    "KACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAo" +
-    "AKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAo" +
-    "AKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgAoAKACgD/9k=";

+ 0 - 19
web/apps/cast/src/constants/urls.ts

@@ -1,19 +0,0 @@
-export const ENTE_WEBSITE_LINK = "https://ente.io";
-
-export const ML_BLOG_LINK = "https://ente.io/blog/desktop-ml-beta";
-
-export const FACE_SEARCH_PRIVACY_POLICY_LINK =
-    "https://ente.io/privacy#8-biometric-information-privacy-policy";
-
-export const SUPPORT_EMAIL = "support@ente.io";
-
-export const APP_DOWNLOAD_URL = "https://ente.io/download/desktop";
-
-export const FEEDBACK_EMAIL = "feedback@ente.io";
-
-export const DELETE_ACCOUNT_EMAIL = "account-deletion@ente.io";
-
-export const WEB_ROADMAP_URL = "https://github.com/ente-io/ente/discussions";
-
-export const DESKTOP_ROADMAP_URL =
-    "https://github.com/ente-io/ente/discussions";

+ 0 - 25
web/apps/cast/src/services/cache/cacheStorageFactory.ts

@@ -1,25 +0,0 @@
-import { LimitedCacheStorage } from "types/cache/index";
-
-class cacheStorageFactory {
-    getCacheStorage(): LimitedCacheStorage {
-        return transformBrowserCacheStorageToLimitedCacheStorage(caches);
-    }
-}
-
-export const CacheStorageFactory = new cacheStorageFactory();
-
-function transformBrowserCacheStorageToLimitedCacheStorage(
-    caches: CacheStorage,
-): LimitedCacheStorage {
-    return {
-        async open(cacheName) {
-            const cache = await caches.open(cacheName);
-            return {
-                match: cache.match.bind(cache),
-                put: cache.put.bind(cache),
-                delete: cache.delete.bind(cache),
-            };
-        },
-        delete: caches.delete.bind(caches),
-    };
-}

+ 0 - 33
web/apps/cast/src/services/cache/cacheStorageService.ts

@@ -1,33 +0,0 @@
-import { logError } from "@ente/shared/sentry";
-import { CacheStorageFactory } from "./cacheStorageFactory";
-
-const SecurityError = "SecurityError";
-const INSECURE_OPERATION = "The operation is insecure.";
-async function openCache(cacheName: string) {
-    try {
-        return await CacheStorageFactory.getCacheStorage().open(cacheName);
-    } catch (e) {
-        // ignoring insecure operation error, as it is thrown in incognito mode in firefox
-        if (e.name === SecurityError && e.message === INSECURE_OPERATION) {
-            // no-op
-        } else {
-            // log and ignore, we don't want to break the caller flow, when cache is not available
-            logError(e, "openCache failed");
-        }
-    }
-}
-async function deleteCache(cacheName: string) {
-    try {
-        return await CacheStorageFactory.getCacheStorage().delete(cacheName);
-    } catch (e) {
-        // ignoring insecure operation error, as it is thrown in incognito mode in firefox
-        if (e.name === SecurityError && e.message === INSECURE_OPERATION) {
-            // no-op
-        } else {
-            // log and ignore, we don't want to break the caller flow, when cache is not available
-            logError(e, "deleteCache failed");
-        }
-    }
-}
-
-export const CacheStorageService = { open: openCache, delete: deleteCache };

+ 0 - 12
web/apps/cast/src/services/events.ts

@@ -1,12 +0,0 @@
-import { EventEmitter } from "eventemitter3";
-
-// When registering event handlers,
-// handle errors to avoid unhandled rejection or propagation to emit call
-
-export enum Events {
-    LOGOUT = "logout",
-    FILE_UPLOADED = "fileUploaded",
-    LOCAL_FILES_UPDATED = "localFilesUpdated",
-}
-
-export const eventBus = new EventEmitter<Events>();

+ 0 - 13
web/apps/cast/src/services/livePhotoService.ts

@@ -30,16 +30,3 @@ export const decodeLivePhoto = async (file: EnteFile, zipBlob: Blob) => {
     }
     return livePhoto;
 };
-
-export const encodeLivePhoto = async (livePhoto: LivePhoto) => {
-    const zip = new JSZip();
-    zip.file(
-        "image" + getFileExtensionWithDot(livePhoto.imageNameTitle),
-        livePhoto.image,
-    );
-    zip.file(
-        "video" + getFileExtensionWithDot(livePhoto.videoNameTitle),
-        livePhoto.video,
-    );
-    return await zip.generateAsync({ type: "uint8array" });
-};

+ 0 - 0
web/apps/cast/src/types/gallery/index.ts


+ 0 - 43
web/apps/cast/src/types/upload/ui.ts

@@ -1,43 +0,0 @@
-import { UPLOAD_RESULT, UPLOAD_STAGES } from "constants/upload";
-
-export type FileID = number;
-export type FileName = string;
-
-export type PercentageUploaded = number;
-export type UploadFileNames = Map<FileID, FileName>;
-
-export interface UploadCounter {
-    finished: number;
-    total: number;
-}
-
-export interface InProgressUpload {
-    localFileID: FileID;
-    progress: PercentageUploaded;
-}
-
-export interface FinishedUpload {
-    localFileID: FileID;
-    result: UPLOAD_RESULT;
-}
-
-export type InProgressUploads = Map<FileID, PercentageUploaded>;
-
-export type FinishedUploads = Map<FileID, UPLOAD_RESULT>;
-
-export type SegregatedFinishedUploads = Map<UPLOAD_RESULT, FileID[]>;
-
-export interface ProgressUpdater {
-    setPercentComplete: React.Dispatch<React.SetStateAction<number>>;
-    setUploadCounter: React.Dispatch<React.SetStateAction<UploadCounter>>;
-    setUploadStage: React.Dispatch<React.SetStateAction<UPLOAD_STAGES>>;
-    setInProgressUploads: React.Dispatch<
-        React.SetStateAction<InProgressUpload[]>
-    >;
-    setFinishedUploads: React.Dispatch<
-        React.SetStateAction<SegregatedFinishedUploads>
-    >;
-    setUploadFilenames: React.Dispatch<React.SetStateAction<UploadFileNames>>;
-    setHasLivePhotos: React.Dispatch<React.SetStateAction<boolean>>;
-    setUploadProgressView: React.Dispatch<React.SetStateAction<boolean>>;
-}

+ 0 - 42
web/apps/cast/src/utils/file/index.ts

@@ -1,6 +1,4 @@
 import { logError } from "@ente/shared/sentry";
-import { LS_KEYS, getData } from "@ente/shared/storage/localStorage";
-import { User } from "@ente/shared/user/types";
 import { FILE_TYPE, RAW_FORMATS } from "constants/file";
 import CastDownloadManager from "services/castDownloadManager";
 import { decodeLivePhoto } from "services/livePhotoService";
@@ -122,10 +120,6 @@ export function generateStreamFromArrayBuffer(data: Uint8Array) {
     });
 }
 
-export function isRawFile(exactType: string) {
-    return RAW_FORMATS.includes(exactType.toLowerCase());
-}
-
 export function isRawFileFromFileName(fileName: string) {
     for (const rawFormat of RAW_FORMATS) {
         if (fileName.toLowerCase().endsWith(rawFormat)) {
@@ -148,42 +142,6 @@ export function mergeMetadata(files: EnteFile[]): EnteFile[] {
     });
 }
 
-export async function getFileFromURL(fileURL: string) {
-    const fileBlob = await (await fetch(fileURL)).blob();
-    const fileFile = new File([fileBlob], "temp");
-    return fileFile;
-}
-
-export function getUniqueFiles(files: EnteFile[]) {
-    const idSet = new Set<number>();
-    const uniqueFiles = files.filter((file) => {
-        if (!idSet.has(file.id)) {
-            idSet.add(file.id);
-            return true;
-        } else {
-            return false;
-        }
-    });
-
-    return uniqueFiles;
-}
-
-export const isImageOrVideo = (fileType: FILE_TYPE) =>
-    [FILE_TYPE.IMAGE, FILE_TYPE.VIDEO].includes(fileType);
-
-export const createTypedObjectURL = async (blob: Blob, fileName: string) => {
-    const type = await getFileType(new File([blob], fileName));
-    return URL.createObjectURL(new Blob([blob], { type: type.mimeType }));
-};
-
-export const getUserOwnedFiles = (files: EnteFile[]) => {
-    const user: User = getData(LS_KEYS.USER);
-    if (!user?.id) {
-        throw Error("user missing");
-    }
-    return files.filter((file) => file.ownerID === user.id);
-};
-
 export const getPreviewableImage = async (
     file: EnteFile,
     castToken: string,

+ 0 - 57
web/apps/cast/src/utils/magicMetadata/index.ts

@@ -1,57 +0,0 @@
-import { MagicMetadataCore } from "types/magicMetadata";
-import ComlinkCryptoWorker from "utils/comlink/ComlinkCryptoWorker";
-
-export async function updateMagicMetadata<T>(
-    magicMetadataUpdates: T,
-    originalMagicMetadata?: MagicMetadataCore<T>,
-    decryptionKey?: string,
-): Promise<MagicMetadataCore<T>> {
-    const cryptoWorker = await ComlinkCryptoWorker.getInstance();
-
-    if (!originalMagicMetadata) {
-        originalMagicMetadata = getNewMagicMetadata<T>();
-    }
-
-    if (typeof originalMagicMetadata?.data === "string") {
-        originalMagicMetadata.data = await cryptoWorker.decryptMetadata(
-            originalMagicMetadata.data,
-            originalMagicMetadata.header,
-            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,
-        count: Object.keys(nonEmptyMagicMetadataProps).length,
-    };
-
-    return magicMetadata;
-}
-
-export const getNewMagicMetadata = <T>(): MagicMetadataCore<T> => {
-    return {
-        version: 1,
-        data: null,
-        header: null,
-        count: 0,
-    };
-};
-
-export const getNonEmptyMagicMetadataProps = <T>(magicMetadataProps: T): T => {
-    return Object.fromEntries(
-        Object.entries(magicMetadataProps).filter(
-            // eslint-disable-next-line @typescript-eslint/no-unused-vars
-            ([_, v]) => v !== null && v !== undefined,
-        ),
-    ) as T;
-};