Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Remove dead code from cast

Manav Rathi049a240916a9
diff --git a/web/apps/cast/src/services/castDownloadManager.ts b/web/apps/cast/src/services/castDownloadManager.ts
index 2dea0451eb..a99f0481da 100644
--- a/web/apps/cast/src/services/castDownloadManager.ts
+++ b/web/apps/cast/src/services/castDownloadManager.ts
@@ -57,7 +57,6 @@ class CastDownloadManager {
reader.read().then(async ({ done, value }) => {
// Is there more data to read?
if (!done) {
- downloadedBytes += value.byteLength;
const buffer = new Uint8Array(
data.byteLength + value.byteLength,
);
diff --git a/web/apps/cast/src/utils/file/index.ts b/web/apps/cast/src/utils/file/index.ts
index 6dc80d8982..fb7e4ac673 100644
--- a/web/apps/cast/src/utils/file/index.ts
+++ b/web/apps/cast/src/utils/file/index.ts
@@ -26,8 +26,6 @@ import {
import { FileTypeInfo } from "types/upload";
import ComlinkCryptoWorker from "utils/comlink/ComlinkCryptoWorker";
-const WAIT_TIME_IMAGE_CONVERSION = 30 * 1000;
-
export function sortFiles(files: EnteFile[], sortAsc = false) {
// sort based on the time of creation time of the file,
// for files with same creation time, sort based on the time of last modification
@@ -43,20 +41,6 @@ export function sortFiles(files: EnteFile[], sortAsc = false) {
});
}
-export function sortTrashFiles(files: EnteFile[]) {
- return files.sort((a, b) => {
- if (a.deleteBy === b.deleteBy) {
- if (a.metadata.creationTime === b.metadata.creationTime) {
- return (
- b.metadata.modificationTime - a.metadata.modificationTime
- );
- }
- return b.metadata.creationTime - a.metadata.creationTime;
- }
- return a.deleteBy - b.deleteBy;
- });
-}
-
export async function decryptFile(
file: EncryptedEnteFile,
collectionKey: string,
@@ -371,106 +355,6 @@ export const getUserOwnedFiles = (files: EnteFile[]) => {
return files.filter((file) => file.ownerID === user.id);
};
-// doesn't work on firefox
-export const copyFileToClipboard = async (fileUrl: string) => {
- const canvas = document.createElement("canvas");
- const canvasCTX = canvas.getContext("2d");
- const image = new Image();
-
- const blobPromise = new Promise<Blob>((resolve, reject) => {
- let timeout: NodeJS.Timeout = null;
- try {
- image.setAttribute("src", fileUrl);
- image.onload = () => {
- canvas.width = image.width;
- canvas.height = image.height;
- canvasCTX.drawImage(image, 0, 0, image.width, image.height);
- canvas.toBlob(
- (blob) => {
- resolve(blob);
- },
- "image/png",
- 1,
- );
-
- clearTimeout(timeout);
- };
- } catch (e) {
- void logError(e, "failed to copy to clipboard");
- reject(e);
- } finally {
- clearTimeout(timeout);
- }
- timeout = setTimeout(
- () => reject(Error(CustomError.WAIT_TIME_EXCEEDED)),
- WAIT_TIME_IMAGE_CONVERSION,
- );
- });
-
- const { ClipboardItem } = window;
-
- await navigator.clipboard
- .write([new ClipboardItem({ "image/png": blobPromise })])
- .catch((e) => logError(e, "failed to copy to clipboard"));
-};
-
-export function getLatestVersionFiles(files: EnteFile[]) {
- const latestVersionFiles = new Map<string, EnteFile>();
- files.forEach((file) => {
- const uid = `${file.collectionID}-${file.id}`;
- if (
- !latestVersionFiles.has(uid) ||
- latestVersionFiles.get(uid).updationTime < file.updationTime
- ) {
- latestVersionFiles.set(uid, file);
- }
- });
- return Array.from(latestVersionFiles.values()).filter(
- (file) => !file.isDeleted,
- );
-}
-
-export function getPersonalFiles(files: EnteFile[], user: User) {
- if (!user?.id) {
- throw Error("user missing");
- }
- return files.filter((file) => file.ownerID === user.id);
-}
-
-export function getIDBasedSortedFiles(files: EnteFile[]) {
- return files.sort((a, b) => a.id - b.id);
-}
-
-export function constructFileToCollectionMap(files: EnteFile[]) {
- const fileToCollectionsMap = new Map<number, number[]>();
- (files ?? []).forEach((file) => {
- if (!fileToCollectionsMap.get(file.id)) {
- fileToCollectionsMap.set(file.id, []);
- }
- fileToCollectionsMap.get(file.id).push(file.collectionID);
- });
- return fileToCollectionsMap;
-}
-
-export const shouldShowAvatar = (file: EnteFile, user: User) => {
- if (!file || !user) {
- return false;
- }
- // is Shared file
- else if (file.ownerID !== user.id) {
- return true;
- }
- // is public collected file
- else if (
- file.ownerID === user.id &&
- file.pubMagicMetadata?.data?.uploaderName
- ) {
- return true;
- } else {
- return false;
- }
-};
-
export const getPreviewableImage = async (
file: EnteFile,
castToken: string,
diff --git a/web/apps/cast/src/utils/file/livePhoto.ts b/web/apps/cast/src/utils/file/livePhoto.ts
deleted file mode 100644
index 7d687217ce..0000000000
--- a/web/apps/cast/src/utils/file/livePhoto.ts
+++ /dev/null
@@ -1,42 +0,0 @@
-import { FILE_TYPE } from "constants/file";
-import { getFileExtension } from "utils/file";
-
-const IMAGE_EXTENSIONS = [
- "heic",
- "heif",
- "jpeg",
- "jpg",
- "png",
- "gif",
- "bmp",
- "tiff",
- "webp",
-];
-
-const VIDEO_EXTENSIONS = [
- "mov",
- "mp4",
- "m4v",
- "avi",
- "wmv",
- "flv",
- "mkv",
- "webm",
- "3gp",
- "3g2",
- "avi",
- "ogv",
- "mpg",
- "mp",
-];
-
-export function getFileTypeFromExtensionForLivePhotoClustering(
- filename: string,
-) {
- const extension = getFileExtension(filename)?.toLowerCase();
- if (IMAGE_EXTENSIONS.includes(extension)) {
- return FILE_TYPE.IMAGE;
- } else if (VIDEO_EXTENSIONS.includes(extension)) {
- return FILE_TYPE.VIDEO;
- }
-}