π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Deduplicate albums shared helpers
Anand Baburajan0446fab0f1d5
diff --git a/web/apps/albums/src/public-album/components/FileList.tsx b/web/apps/albums/src/public-album/components/FileList.tsxindex 20dd024845..9c3f5baff2 100644--- a/web/apps/albums/src/public-album/components/FileList.tsx+++ b/web/apps/albums/src/public-album/components/FileList.tsx@@ -5,15 +5,6 @@ import {handleSelectCreator,handleSelectCreatorMulti,} from "@/public-album/utils/photo-frame";-import {- LoadingThumbnail,- StaticThumbnail,-} from "@/shared/ui/media/PlaceholderThumbnails";-import {- computeThumbnailGridLayoutParams,- thumbnailGap,- type ThumbnailGridLayoutParams,-} from "@/shared/utils/thumbnail-grid-layout";import AlbumOutlinedIcon from "@mui/icons-material/AlbumOutlined";import PlayArrowRoundedIcon from "@mui/icons-material/PlayArrowRounded";import PlayCircleOutlineOutlinedIcon from "@mui/icons-material/PlayCircleOutlineOutlined";@@ -23,6 +14,15 @@ import log from "ente-base/log";import type { EnteFile } from "ente-media/file";import { fileDurationString } from "ente-media/file-metadata";import { FileType } from "ente-media/file-type";+import {+ LoadingThumbnail,+ StaticThumbnail,+} from "ente-new/photos/components/PlaceholderThumbnails";+import {+ computeThumbnailGridLayoutParams,+ thumbnailGap,+ type ThumbnailGridLayoutParams,+} from "ente-new/photos/components/utils/thumbnail-grid-layout";import { batch } from "ente-utils/array";import { t } from "i18next";import React, {diff --git a/web/apps/albums/src/public-album/data/api/public-file-data.ts b/web/apps/albums/src/public-album/data/api/public-file-data.tsdeleted file mode 100644index 0cc02ebf6e..0000000000--- a/web/apps/albums/src/public-album/data/api/public-file-data.ts+++ /dev/null@@ -1,143 +0,0 @@-import { requirePublicAlbumsCredentials } from "@/public-album/data/auth/public-link-credentials";-import {- authenticatedPublicAlbumsRequestHeaders,- ensureOk,- type PublicAlbumsCredentials,-} from "ente-base/http";-import { apiURL } from "ente-base/origins";-import { nullToUndefined } from "ente-utils/transform";-import { z } from "zod";--/**- * [Note: File data APIs]- *- * Remote provides some APIs that talk in terms of "file data", which refers to- * all the files (original or derived) associated with an {@link EnteFile}.- *- * For example, for each original image that the user uploads, there will be an- * associated thumbnail file, potentially one or more preview files (optimized- * for size or compatibility across devices), and possibly more such files in- * the future.- *- * There are specialized APIs for fetching and uploading the originals and the- * thumbnails. But for the other associated data, we can use the file data APIs.- */-type FileDataType = "vid_preview" /* See: [Note: Video playlist and preview] */;--const RemoteFileData = z.object({- /**- * The ID of the {@link EnteFile} with which this file data is associated.- */- fileID: z.number(),- /**- * Base64 representation of the encrypted data. Its plaintext contents will- * be specific to each file data type.- */- encryptedData: z.string(),- /**- * Base64 representation of the header that should be passed when decrypting- * {@link encryptedData}. See the {@link decryptMetadata} function in the- * crypto layer.- */- decryptionHeader: z.string(),- /**- * The epoch microseconds when this file data entry was last upserted.- * Optional for compatibility with older museum responses.- */- updatedAt: z.number().nullish().transform(nullToUndefined),-});--type RemoteFileData = z.infer<typeof RemoteFileData>;--/**- * Fetch file data of a particular type for a single file.- *- * Returns `undefined` if no file data of the given type has been uploaded for- * this file yet (e.g. if type was "vid_preview", this would indicate that a- * video preview has been generated for this file yet).- *- * @param publicAlbumsCredentials Credentials for the current public album. If- * omitted, the currently configured public album credentials are used.- */-export const fetchFileData = async (- type: FileDataType,- fileID: number,- publicAlbumsCredentials?: PublicAlbumsCredentials,-): Promise<RemoteFileData | undefined> => {- const credentials = requirePublicAlbumsCredentials(publicAlbumsCredentials);- const params = new URLSearchParams({- type,- fileID: fileID.toString(),- // Ask museum to respond with 204 instead of 404 if no playlist exists- // for the given file.- preferNoContent: "true",- });-- const url = await apiURL("/public-collection/files/data/fetch");- const headers = authenticatedPublicAlbumsRequestHeaders(credentials);- const res = await fetch(`${url}?${params.toString()}`, { headers });-- if (res.status == 204) return undefined;- // We're passing `preferNoContent` so the expected response is 204, but this- // might be a self hoster running an older museum that does not recognize- // that flag, so retain the old behavior. This fallback can be removed in a- // few months (tag: Migration, note added May 2025).- if (res.status == 404) return undefined;- ensureOk(res);- return z.object({ data: RemoteFileData }).parse(await res.json()).data;-};--/**- * Fetch the preview file data the given file.- *- * @param type The {@link FileDataType} which we want.- *- * @param fileIDs The id of the files for which we want the file preview data.- *- * @param publicAlbumsCredentials Credentials for the current public album. If- * omitted, the currently configured public album credentials are used.- *- * @returns the (pre-signed) URL to the preview data, or undefined if there is- * not preview data of the given type for the given file yet.- *- * [Note: File data vs file preview data]- *- * In museum's ontology, there is a distinction between two concepts:- *- * S3 metadata (museum term, the APIs call it "file data") is data that museum- * uploads on behalf of the client. e.g.,- *- * - Preview video playlist.- *- * S3 file data (museum term, the APIs call it "file preview data") is data that- * a client itself uploads. e.g.,- *- * - The preview video itself.- *- * - Additional preview images.- *- * [Note: Video playlist and preview]- *- * For a streaming video, both these concepts are needed:- *- * - The encrypted HLS playlist is stored as "file data" of type "vid_preview",- *- * - The encrypted video chunks that the playlist refers to are stored as "file- * preview data" of type "vid_preview".- */-export const fetchFilePreviewData = async (- type: FileDataType,- fileID: number,- publicAlbumsCredentials?: PublicAlbumsCredentials,-): Promise<string | undefined> => {- const credentials = requirePublicAlbumsCredentials(publicAlbumsCredentials);- const params = new URLSearchParams({ type, fileID: fileID.toString() });-- const headers = authenticatedPublicAlbumsRequestHeaders(credentials);- const url = await apiURL("/public-collection/files/data/preview");- const res = await fetch(`${url}?${params.toString()}`, { headers });-- if (res.status == 404) return undefined;- ensureOk(res);- return z.object({ url: z.string() }).parse(await res.json()).url;-};diff --git a/web/apps/albums/src/public-album/media/video/preview.ts b/web/apps/albums/src/public-album/media/video/preview.tsindex 9a1d5e0d10..6de6333996 100644--- a/web/apps/albums/src/public-album/media/video/preview.ts+++ b/web/apps/albums/src/public-album/media/video/preview.ts@@ -1,11 +1,11 @@-import {- fetchFileData,- fetchFilePreviewData,-} from "@/public-album/data/api/public-file-data";import { decryptBlobBytes } from "ente-base/crypto";import type { EncryptedBlob } from "ente-base/crypto/types";import type { PublicAlbumsCredentials } from "ente-base/http";import log from "ente-base/log";+import {+ fetchFileData,+ fetchFilePreviewData,+} from "ente-gallery/services/file-data";import { fileLogID, type EnteFile } from "ente-media/file";import { FileType } from "ente-media/file-type";import { ensurePrecondition } from "ente-utils/ensure";diff --git a/web/apps/albums/src/public-album/page/PublicAlbumPage.tsx b/web/apps/albums/src/public-album/page/PublicAlbumPage.tsxindex 348cae5688..8e8bdb44d3 100644--- a/web/apps/albums/src/public-album/page/PublicAlbumPage.tsx+++ b/web/apps/albums/src/public-album/page/PublicAlbumPage.tsx@@ -32,15 +32,6 @@ import { type FileViewerInitialSidebar } from "@/public-album/viewer/components/import type { PublicAlbumSingleFileViewerProps } from "@/public-album/viewer/components/PublicAlbumSingleFileViewer";import { type PublicFeedItemClickInfo } from "@/public-album/viewer/components/PublicFeedSidebar";import { LazyPublicFeedSidebar } from "@/public-album/viewer/lib/lazy";-import {- GalleryItemsHeaderAdapter,- GalleryItemsSummary,-} from "@/shared/ui/gallery/GalleryItemsHeader";-import {- LoadingThumbnail,- StaticThumbnail,-} from "@/shared/ui/media/PlaceholderThumbnails";-import { thumbnailGap } from "@/shared/utils/thumbnail-grid-layout";import CheckIcon from "@mui/icons-material/Check";import CloseIcon from "@mui/icons-material/Close";import {@@ -79,6 +70,15 @@ import type { Collection } from "ente-media/collection";import { type EnteFile } from "ente-media/file";import { fileFileName } from "ente-media/file-metadata";import { FileType } from "ente-media/file-type";+import {+ GalleryItemsHeaderAdapter,+ GalleryItemsSummary,+} from "ente-new/photos/components/gallery/ListHeader";+import {+ LoadingThumbnail,+ StaticThumbnail,+} from "ente-new/photos/components/PlaceholderThumbnails";+import { thumbnailGap } from "ente-new/photos/components/utils/thumbnail-grid-layout";import { t } from "i18next";import dynamic from "next/dynamic";import { useRouter } from "next/router";diff --git a/web/apps/albums/src/public-album/upload/components/Upload.tsx b/web/apps/albums/src/public-album/upload/components/Upload.tsxindex ed49c8cbee..4e194abc04 100644--- a/web/apps/albums/src/public-album/upload/components/Upload.tsx+++ b/web/apps/albums/src/public-album/upload/components/Upload.tsx@@ -25,7 +25,6 @@ import type {UploadItemWithCollection,} from "@/public-album/upload/services/upload-manager";import { uploadManager } from "@/public-album/upload/services/upload-manager";-import { hasReliableCanvasReadback } from "@/public-album/upload/utils/canvas-integrity";import { Album02Icon, Folder01Icon } from "@hugeicons/core-free-icons";import { HugeiconsIcon } from "@hugeicons/react";import ChevronRightIcon from "@mui/icons-material/ChevronRight";@@ -50,14 +49,15 @@ import { useBaseContext } from "ente-base/context";import { basename } from "ente-base/file-name";import type { PublicAlbumsCredentials } from "ente-base/http";import log from "ente-base/log";+import { CanvasReadbackBlockedDialog } from "ente-gallery/components/upload/CanvasReadbackBlockedDialog";import { UploadProgress } from "ente-gallery/components/UploadProgress";import { useFileInput } from "ente-gallery/components/utils/use-file-input";+import { hasReliableCanvasReadback } from "ente-gallery/utils/upload/canvas-integrity";import { type Collection } from "ente-media/collection";import type { EnteFile } from "ente-media/file";import { firstNonEmpty } from "ente-utils/array";import { t } from "i18next";import React, { useCallback, useEffect, useRef, useState } from "react";-import { CanvasReadbackBlockedDialog } from "./CanvasReadbackBlockedDialog";interface RemotePullOpts {/**diff --git a/web/apps/albums/src/shared/ui/gallery/GalleryItemsHeader.tsx b/web/apps/albums/src/shared/ui/gallery/GalleryItemsHeader.tsxdeleted file mode 100644index 1979ff5fe5..0000000000--- a/web/apps/albums/src/shared/ui/gallery/GalleryItemsHeader.tsx+++ /dev/null@@ -1,88 +0,0 @@-import {- Box,- Stack,- styled,- Typography,- type TypographyProps,-} from "@mui/material";-import { t } from "i18next";-import React from "react";--interface GalleryItemsSummaryProps {- /**- * The name / title for the items that are being shown.- */- name: string;- /**- * Optional extra props to pass to the {@link Typography} component that- * shows {@link name}- */- nameProps?: TypographyProps;- /**- * The number of items being shown.- */- fileCount: number;- /**- * An optional element, usually an icon, placed after the file count.- */- endIcon?: React.ReactNode;- /**- * An optional click handler for the name.- *- * Note: Do not use this as the primary / only mechanism for the- * corresponding functionality to be invoked, since this click handler will- * be accessible only to sighted mouse users. However, it is fine to use it- * as an alternate means of invoking some function.- */- onNameClick?: () => void;-}--/**- * A component suitable for being used as a summary displayed on top of the of a- * list of photos (or other items) shown in the gallery.- */-export const GalleryItemsSummary: React.FC<GalleryItemsSummaryProps> = ({- name,- nameProps,- fileCount,- endIcon,- onNameClick,-}) => (- <div>- <Typography variant="h3" {...(nameProps ?? {})} onClick={onNameClick}>- {name}- </Typography>-- <Stack- direction="row"- sx={{- gap: 1.5,- // Keep height the same even when there is no endIcon- minHeight: "24px",- }}- >- <Typography variant="small" sx={{ color: "text.muted" }}>- {t("photos_count", { count: fileCount })}- </Typography>- {endIcon && (- <Box sx={{ svg: { fontSize: "17px", color: "text.muted" } }}>- {endIcon}- </Box>- )}- </Stack>- </div>-);--/**- * A component suitable for wrapping a component which is acting like a gallery- * items header so that it fills the entire width (and acts like a "header")- * when it is displayed in the gallery view.- *- * The header view (e.g. a {@link GalleryItemsSummary}) is displayed as part of- * the gallery items list itself so that it scrolls alongwith the items. This- * wrapper makes it take the full width of the "row" that it occupies.- */-export const GalleryItemsHeaderAdapter = styled("div")`- width: 100%;- margin-bottom: 12px;-`;diff --git a/web/apps/albums/src/shared/ui/media/PlaceholderThumbnails.tsx b/web/apps/albums/src/shared/ui/media/PlaceholderThumbnails.tsxdeleted file mode 100644index cf631d541e..0000000000--- a/web/apps/albums/src/shared/ui/media/PlaceholderThumbnails.tsx+++ /dev/null@@ -1,52 +0,0 @@-import PhotoOutlinedIcon from "@mui/icons-material/PhotoOutlined";-import PlayCircleOutlineOutlinedIcon from "@mui/icons-material/PlayCircleOutlineOutlined";-import { styled } from "@mui/material";-import { Overlay } from "ente-base/components/containers";-import { FileType } from "ente-media/file-type";-import React from "react";--/**- * A thumbnail shown when we're loading the thumbnail for a file.- */-export const LoadingThumbnail = () => (- <Overlay sx={{ backgroundColor: "fill.faint", borderRadius: "4px" }} />-);--interface StaticThumbnailProps {- /**- * The type of the file for which we're showing the placeholder thumbnail.- *- * Expected to be one of {@link FileType}.- */- fileType: number;-}--/**- * A thumbnail shown when a file does not have a thumbnail.- */-export const StaticThumbnail: React.FC<StaticThumbnailProps> = ({- fileType,-}) => (- <CenteredOverlay- sx={{- backgroundColor: "fill.faint",- borderWidth: "1px",- borderStyle: "solid",- borderColor: "stroke.faint",- borderRadius: "4px",- "& > svg": { color: "stroke.muted", fontSize: "50px" },- }}- >- {fileType != FileType.video ? (- <PhotoOutlinedIcon />- ) : (- <PlayCircleOutlineOutlinedIcon />- )}- </CenteredOverlay>-);--const CenteredOverlay = styled(Overlay)`- display: flex;- justify-content: center;- align-items: center;-`;diff --git a/web/apps/albums/src/shared/utils/thumbnail-grid-layout.ts b/web/apps/albums/src/shared/utils/thumbnail-grid-layout.tsdeleted file mode 100644index cfc1c015cb..0000000000--- a/web/apps/albums/src/shared/utils/thumbnail-grid-layout.ts+++ /dev/null@@ -1,90 +0,0 @@-export const thumbnailGap = 4;-export const thumbnailMaxHeight = 180;-export const thumbnailMaxWidth = 180;-export const thumbnailLayoutMinColumns = 4;--export interface ThumbnailGridLayoutParams {- /**- * The overall width available to us.- *- * This is the height that is the input to the computation, stashed here so- * that other parts of the code downstream can also get at it if needed.- */- containerWidth: number;- /**- * `true` if the container width is classified as a smaller screen for the- * purpose of the thumbnail grid, and some dimensions are reduced to account- * for the lesser space available to us.- */- isSmallerLayout: boolean;- /**- * The inline padding (px) of the thumbnail grid.- */- paddingInline: number;- /**- * The number of columns in the thumbnail grid.- */- columns: number;- /**- * The width (px) of each item.- */- itemWidth: number;- /**- * The height (px) of each item.- */- itemHeight: number;- /**- * The gap (px) between each grid item.- */- gap: number;-}--/**- * Determine the layout parameters for a grid of thumbnails that would best fit- * the given width under various constraints.- *- * @param containerWidth The width available to the container. In our case,- * since the thumbnail grids span the entire available width, this is the width- * of the page itself.- */-export const computeThumbnailGridLayoutParams = (- containerWidth: number,-): ThumbnailGridLayoutParams => {- const isSmallerLayout = !(- containerWidth >- thumbnailLayoutMinColumns * thumbnailMaxWidth- );- const paddingInline = getGapFromScreenEdge(containerWidth);- const fittableColumns = getFractionFittableColumns(containerWidth);-- let columns = Math.floor(fittableColumns);- if (columns < thumbnailLayoutMinColumns) {- columns = thumbnailLayoutMinColumns;- }-- const shrinkRatio = getShrinkRatio(containerWidth, columns);- const itemHeight = thumbnailMaxHeight * shrinkRatio;- const itemWidth = thumbnailMaxWidth * shrinkRatio;- const gap = thumbnailGap;-- return {- containerWidth,- isSmallerLayout,- paddingInline,- columns,- itemWidth,- itemHeight,- gap,- };-};--const getFractionFittableColumns = (width: number): number =>- (width - 2 * getGapFromScreenEdge(width) + thumbnailGap) /- (thumbnailMaxWidth + thumbnailGap);--const getGapFromScreenEdge = (width: number) =>- width > thumbnailLayoutMinColumns * thumbnailMaxWidth ? 24 : 4;--const getShrinkRatio = (width: number, columns: number) =>- (width - 2 * getGapFromScreenEdge(width) - (columns - 1) * thumbnailGap) /- (columns * thumbnailMaxWidth);diff --git a/web/apps/photos/src/components/CanvasReadbackBlockedDialog.tsx b/web/apps/photos/src/components/CanvasReadbackBlockedDialog.tsxdeleted file mode 100644index 24aaed5ffe..0000000000--- a/web/apps/photos/src/components/CanvasReadbackBlockedDialog.tsx+++ /dev/null@@ -1,161 +0,0 @@-import CloseIcon from "@mui/icons-material/Close";-import ErrorOutlineRoundedIcon from "@mui/icons-material/ErrorOutlineRounded";-import {- Box,- Dialog,- IconButton,- Link,- styled,- Typography,- type DialogProps,-} from "@mui/material";-import { type ModalVisibilityProps } from "ente-base/components/utils/modal";-import { t } from "i18next";-import React from "react";--export type CanvasReadbackBlockedDialogProps = ModalVisibilityProps;--export const CanvasReadbackBlockedDialog: React.FC<- CanvasReadbackBlockedDialogProps-> = ({ open, onClose }) => (- <StyledDialog open={open} onClose={onClose}>- <DialogWrapper>- <CloseButton onClick={onClose}>- <CloseIcon sx={{ fontSize: 20 }} />- </CloseButton>- <ContentContainer>- <IllustrationWrapper>- <ErrorIconContainer>- <ErrorOutlineRoundedIcon sx={{ fontSize: 48 }} />- </ErrorIconContainer>- </IllustrationWrapper>-- <TitleSection>- <Title>{t("thumbnail_generation_failed")}</Title>- <Subtitle>- {t("canvas_blocked_upload_description")}{" "}- <HelpLink- href="https://ente.com/help/photos/faq/troubleshooting#thumbnails"- target="_blank"- rel="noopener"- >- {t("learn_how")}- </HelpLink>- .- </Subtitle>- </TitleSection>- </ContentContainer>- </DialogWrapper>- </StyledDialog>-);--const StyledDialog = styled(Dialog)<DialogProps>(({ theme }) => ({- "& .MuiDialog-paper": {- width: 381,- maxWidth: "calc(100% - 32px)",- borderRadius: 28,- backgroundColor: "#fff",- padding: 0,- margin: 16,- overflow: "visible",- boxShadow: "none",- border: "1px solid #E0E0E0",- ...theme.applyStyles("dark", {- backgroundColor: "#1b1b1b",- border: "1px solid rgba(255, 255, 255, 0.18)",- }),- },- "& .MuiBackdrop-root": { backgroundColor: "rgba(0, 0, 0, 0.5)" },-}));--const DialogWrapper = styled(Box)(() => ({- position: "relative",- padding: "48px 16px 16px 16px",-}));--const CloseButton = styled(IconButton)(({ theme }) => ({- position: "absolute",- top: 11,- right: 12,- backgroundColor: "#FAFAFA",- color: "#000",- padding: 10,- "&:hover": { backgroundColor: "#F0F0F0" },- ...theme.applyStyles("dark", {- backgroundColor: "rgba(255, 255, 255, 0.12)",- color: "#fff",- "&:hover": { backgroundColor: "rgba(255, 255, 255, 0.16)" },- }),-}));--const ContentContainer = styled(Box)(() => ({- display: "flex",- flexDirection: "column",- alignItems: "center",- gap: 16,-}));--const IllustrationWrapper = styled(Box)(() => ({- display: "flex",- justifyContent: "center",- alignItems: "center",- marginBottom: 8,-}));--const ErrorIconContainer = styled(Box)(({ theme }) => ({- width: 92,- height: 92,- borderRadius: 56,- display: "flex",- alignItems: "center",- justifyContent: "center",- backgroundColor: "rgba(229, 57, 53, 0.12)",- color: "#E53935",- ...theme.applyStyles("dark", {- backgroundColor: "rgba(255, 138, 128, 0.15)",- color: "#FF8A80",- }),-}));--const TitleSection = styled(Box)(() => ({- display: "flex",- flexDirection: "column",- alignItems: "center",- gap: 9,- width: "100%",- textAlign: "center",- marginBottom: 16,-}));--const Title = styled(Typography)(({ theme }) => ({- fontWeight: 600,- fontSize: 24,- lineHeight: "28px",- letterSpacing: "-0.48px",- color: "#000",- ...theme.applyStyles("dark", { color: "#fff" }),-}));--const Subtitle = styled(Typography)(({ theme }) => ({- fontWeight: 500,- fontSize: 14,- lineHeight: "20px",- color: "#666666",- width: "100%",- padding: "0 8px",- ...theme.applyStyles("dark", { color: "rgba(255, 255, 255, 0.7)" }),-}));--const HelpLink = styled(Link)(({ theme }) => ({- fontWeight: "inherit",- fontSize: 14,- lineHeight: "20px",- color: "#08C225",- textDecorationColor: "#08C225",- "&:hover": { color: "#07A820", textDecorationColor: "#07A820" },- ...theme.applyStyles("dark", {- color: "#22D840",- textDecorationColor: "#22D840",- "&:hover": { color: "#4BE066", textDecorationColor: "#4BE066" },- }),-}));diff --git a/web/apps/photos/src/components/Upload.tsx b/web/apps/photos/src/components/Upload.tsxindex 2a72decdab..b3aa3297cc 100644--- a/web/apps/photos/src/components/Upload.tsx+++ b/web/apps/photos/src/components/Upload.tsx@@ -17,7 +17,6 @@ import {uploadManager,} from "@/services/upload-manager";import watcher from "@/services/watch";-import { hasReliableCanvasReadback } from "@/utils/upload/canvas-integrity";import { Album02Icon, Folder01Icon } from "@hugeicons/core-free-icons";import { HugeiconsIcon } from "@hugeicons/react";import ChevronRightIcon from "@mui/icons-material/ChevronRight";@@ -55,6 +54,7 @@ import type {ZipItem,} from "ente-base/types/ipc";import { type UploadTypeSelectorIntent } from "ente-gallery/components/Upload";+import { CanvasReadbackBlockedDialog } from "ente-gallery/components/upload/CanvasReadbackBlockedDialog";import { UploadProgress } from "ente-gallery/components/UploadProgress";import { useFileInput } from "ente-gallery/components/utils/use-file-input";import {@@ -75,6 +75,7 @@ import {storageLimitExceededErrorMessage,subscriptionExpiredErrorMessage,} from "ente-gallery/services/upload/upload-service";+import { hasReliableCanvasReadback } from "ente-gallery/utils/upload/canvas-integrity";import { CollectionSubType, type Collection } from "ente-media/collection";import type { EnteFile } from "ente-media/file";import { CollectionMappingChoice } from "ente-new/photos/components/CollectionMappingChoice";@@ -100,7 +101,6 @@ import { usePhotosAppContext } from "ente-new/photos/types/context";import { firstNonEmpty } from "ente-utils/array";import { t } from "i18next";import React, { useCallback, useEffect, useRef, useState } from "react";-import { CanvasReadbackBlockedDialog } from "./CanvasReadbackBlockedDialog";interface UploadProps {/** The logged in user, if any. */diff --git a/web/apps/photos/src/utils/upload/canvas-integrity.ts b/web/apps/photos/src/utils/upload/canvas-integrity.tsdeleted file mode 100644index 62f1bc23bb..0000000000--- a/web/apps/photos/src/utils/upload/canvas-integrity.ts+++ /dev/null@@ -1,54 +0,0 @@-const probeWidth = 2;-const probeHeight = 2;--const expectedProbeData = Uint8ClampedArray.from([- 17, 83, 149, 255, 203, 29, 101, 255, 67, 131, 197, 255, 239, 53, 11, 255,-]);--const hasSamePixels = (- lhs: Uint8ClampedArray,- rhs: Uint8ClampedArray,-): boolean => {- if (lhs.length !== rhs.length) return false;- for (let i = 0; i < lhs.length; i++) {- if (lhs[i] !== rhs[i]) return false;- }- return true;-};--export const hasReliableCanvasReadback = (): boolean => {- try {- const canvas = document.createElement("canvas");- canvas.width = probeWidth;- canvas.height = probeHeight;-- const ctx = canvas.getContext("2d", { willReadFrequently: true });- if (!ctx) return false;-- const probeImageData = new ImageData(- new Uint8ClampedArray(expectedProbeData),- probeWidth,- probeHeight,- );- ctx.putImageData(probeImageData, 0, 0);-- const firstReadback = ctx.getImageData(- 0,- 0,- probeWidth,- probeHeight,- ).data;- if (!hasSamePixels(firstReadback, expectedProbeData)) return false;-- const secondReadback = ctx.getImageData(- 0,- 0,- probeWidth,- probeHeight,- ).data;-- return hasSamePixels(firstReadback, secondReadback);- } catch {- return false;- }-};diff --git a/web/apps/albums/src/public-album/upload/components/CanvasReadbackBlockedDialog.tsx b/web/packages/gallery/components/upload/CanvasReadbackBlockedDialog.tsxsimilarity index 100%rename from web/apps/albums/src/public-album/upload/components/CanvasReadbackBlockedDialog.tsxrename to web/packages/gallery/components/upload/CanvasReadbackBlockedDialog.tsxdiff --git a/web/apps/albums/src/public-album/upload/utils/canvas-integrity.ts b/web/packages/gallery/utils/upload/canvas-integrity.tssimilarity index 100%rename from web/apps/albums/src/public-album/upload/utils/canvas-integrity.tsrename to web/packages/gallery/utils/upload/canvas-integrity.ts