Skip to content

armgit / ente

Public Imported from GitHub
0

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

Remove more dead code from cast

Manav Rathi911cdd9448e1
diff --git a/web/apps/cast/src/types/cache/index.ts b/web/apps/cast/src/types/cache/index.ts
deleted file mode 100644
index 8980ca08f4..0000000000
--- a/web/apps/cast/src/types/cache/index.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-export interface LimitedCacheStorage {
- open: (cacheName: string) => Promise<LimitedCache>;
- delete: (cacheName: string) => Promise<boolean>;
-}
-
-export interface LimitedCache {
- match: (key: string) => Promise<Response>;
- put: (key: string, data: Response) => Promise<void>;
- delete: (key: string) => Promise<boolean>;
-}
diff --git a/web/apps/cast/src/types/cast/index.ts b/web/apps/cast/src/types/cast/index.ts
deleted file mode 100644
index f082e433eb..0000000000
--- a/web/apps/cast/src/types/cast/index.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-export interface CastPayload {
- collectionID: number;
- collectionKey: string;
- castToken: string;
-}
diff --git a/web/apps/cast/src/utils/collection/index.ts b/web/apps/cast/src/utils/collection/index.ts
deleted file mode 100644
index bd6c2791d0..0000000000
--- a/web/apps/cast/src/utils/collection/index.ts
+++ /dev/null
@@ -1,147 +0,0 @@
-import { LS_KEYS, getData } from "@ente/shared/storage/localStorage";
-import { User } from "@ente/shared/user/types";
-import {
- CollectionSummaryType,
- CollectionType,
- HIDE_FROM_COLLECTION_BAR_TYPES,
- OPTIONS_NOT_HAVING_COLLECTION_TYPES,
-} from "constants/collection";
-import { COLLECTION_ROLE, Collection } from "types/collection";
-import { SUB_TYPE, VISIBILITY_STATE } from "types/magicMetadata";
-
-export enum COLLECTION_OPS_TYPE {
- ADD,
- MOVE,
- REMOVE,
- RESTORE,
- UNHIDE,
-}
-
-export function getSelectedCollection(
- collectionID: number,
- collections: Collection[],
-) {
- return collections.find((collection) => collection.id === collectionID);
-}
-
-export const shouldShowOptions = (type: CollectionSummaryType) => {
- return !OPTIONS_NOT_HAVING_COLLECTION_TYPES.has(type);
-};
-export const showEmptyTrashQuickOption = (type: CollectionSummaryType) => {
- return type === CollectionSummaryType.trash;
-};
-export const showDownloadQuickOption = (type: CollectionSummaryType) => {
- return (
- type === CollectionSummaryType.folder ||
- type === CollectionSummaryType.favorites ||
- type === CollectionSummaryType.album ||
- type === CollectionSummaryType.uncategorized ||
- type === CollectionSummaryType.hiddenItems ||
- type === CollectionSummaryType.incomingShareViewer ||
- type === CollectionSummaryType.incomingShareCollaborator ||
- type === CollectionSummaryType.outgoingShare ||
- type === CollectionSummaryType.sharedOnlyViaLink ||
- type === CollectionSummaryType.archived ||
- type === CollectionSummaryType.pinned
- );
-};
-export const showShareQuickOption = (type: CollectionSummaryType) => {
- return (
- type === CollectionSummaryType.folder ||
- type === CollectionSummaryType.album ||
- type === CollectionSummaryType.outgoingShare ||
- type === CollectionSummaryType.sharedOnlyViaLink ||
- type === CollectionSummaryType.archived ||
- type === CollectionSummaryType.incomingShareViewer ||
- type === CollectionSummaryType.incomingShareCollaborator ||
- type === CollectionSummaryType.pinned
- );
-};
-export const shouldBeShownOnCollectionBar = (type: CollectionSummaryType) => {
- return !HIDE_FROM_COLLECTION_BAR_TYPES.has(type);
-};
-
-export const getUserOwnedCollections = (collections: Collection[]) => {
- const user: User = getData(LS_KEYS.USER);
- if (!user?.id) {
- throw Error("user missing");
- }
- return collections.filter((collection) => collection.owner.id === user.id);
-};
-
-export const isDefaultHiddenCollection = (collection: Collection) =>
- collection.magicMetadata?.data.subType === SUB_TYPE.DEFAULT_HIDDEN;
-
-export const isHiddenCollection = (collection: Collection) =>
- collection.magicMetadata?.data.visibility === VISIBILITY_STATE.HIDDEN;
-
-export const isQuickLinkCollection = (collection: Collection) =>
- collection.magicMetadata?.data.subType === SUB_TYPE.QUICK_LINK_COLLECTION;
-
-export function isOutgoingShare(collection: Collection, user: User): boolean {
- return collection.owner.id === user.id && collection.sharees?.length > 0;
-}
-
-export function isIncomingShare(collection: Collection, user: User) {
- return collection.owner.id !== user.id;
-}
-
-export function isIncomingViewerShare(collection: Collection, user: User) {
- const sharee = collection.sharees?.find((sharee) => sharee.id === user.id);
- return sharee?.role === COLLECTION_ROLE.VIEWER;
-}
-
-export function isIncomingCollabShare(collection: Collection, user: User) {
- const sharee = collection.sharees?.find((sharee) => sharee.id === user.id);
- return sharee?.role === COLLECTION_ROLE.COLLABORATOR;
-}
-
-export function isSharedOnlyViaLink(collection: Collection) {
- return collection.publicURLs?.length && !collection.sharees?.length;
-}
-
-export function isValidMoveTarget(
- sourceCollectionID: number,
- targetCollection: Collection,
- user: User,
-) {
- return (
- sourceCollectionID !== targetCollection.id &&
- !isHiddenCollection(targetCollection) &&
- !isQuickLinkCollection(targetCollection) &&
- !isIncomingShare(targetCollection, user)
- );
-}
-
-export function isValidReplacementAlbum(
- collection: Collection,
- user: User,
- wantedCollectionName: string,
-) {
- return (
- collection.name === wantedCollectionName &&
- (collection.type === CollectionType.album ||
- collection.type === CollectionType.folder) &&
- !isHiddenCollection(collection) &&
- !isQuickLinkCollection(collection) &&
- !isIncomingShare(collection, user)
- );
-}
-
-export function getCollectionNameMap(
- collections: Collection[],
-): Map<number, string> {
- return new Map<number, string>(
- collections.map((collection) => [collection.id, collection.name]),
- );
-}
-
-export function getNonHiddenCollections(
- collections: Collection[],
-): Collection[] {
- return collections.filter((collection) => !isHiddenCollection(collection));
-}
-
-export function getHiddenCollections(collections: Collection[]): Collection[] {
- return collections.filter((collection) => isHiddenCollection(collection));
-}