Skip to content

armgit / ente

Public Imported from GitHub
0

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

Remove public album web code from photos app

Anand Baburajan98ffcf617186
diff --git a/web/apps/photos/src/components/DownloadStatusNotifications.tsx b/web/apps/photos/src/components/DownloadStatusNotifications.tsx
index e7b5250a49..18b9f64e26 100644
--- a/web/apps/photos/src/components/DownloadStatusNotifications.tsx
+++ b/web/apps/photos/src/components/DownloadStatusNotifications.tsx
@@ -56,10 +56,9 @@ interface DownloadStatusNotificationsProps {
*
* and hidden attribute should be shown.
*
- * This is only relevant in the context of the photos app, and can be
- * omitted by the public albums app. See the documentation of
- * {@link SaveGroup}'s {@link collectionSummaryID} property for why we don't
- * store the collection summary itself.
+ * See the documentation of {@link SaveGroup}'s
+ * {@link collectionSummaryID} property for why we don't store the
+ * collection summary itself.
*/
onShowCollectionSummary?: (
collectionSummaryID: number | undefined,
diff --git a/web/apps/photos/src/components/FileList.tsx b/web/apps/photos/src/components/FileList.tsx
index 8786f538c8..45270173af 100644
--- a/web/apps/photos/src/components/FileList.tsx
+++ b/web/apps/photos/src/components/FileList.tsx
@@ -234,10 +234,6 @@ export interface FileListProps {
footer?: FileListHeaderOrFooter;
/**
* The logged in user, if any.
- *
- * This is only expected to be present when the listing is shown within the
- * photos app, where we have a logged in user. The public albums app can
- * omit this prop.
*/
user?: LocalUser;
/**
@@ -262,15 +258,10 @@ export interface FileListProps {
activePersonID?: string | undefined;
/**
* File IDs of all the files that the user has marked as a favorite.
- *
- * Not set in the context of the public albums app.
*/
favoriteFileIDs?: Set<number>;
/**
* A map from known Ente user IDs to their emails.
- *
- * This is only expected in the context of the photos app, and will be
- * omitted when running in the public albums app.
*/
emailByUserID?: Map<number, string>;
/**
diff --git a/web/apps/photos/src/components/FileListWithViewer.tsx b/web/apps/photos/src/components/FileListWithViewer.tsx
index 00656e072b..80db8dcc94 100644
--- a/web/apps/photos/src/components/FileListWithViewer.tsx
+++ b/web/apps/photos/src/components/FileListWithViewer.tsx
@@ -43,8 +43,6 @@ export type FileListWithViewerProps = {
*
* For more details, see {@link unsyncedFavoriteUpdates} in the gallery
* reducer's documentation.
- *
- * Not set in the context of the public albums app.
*/
onMarkTempDeleted?: (files: EnteFile[]) => void;
/**
@@ -132,11 +130,6 @@ export type FileListWithViewerProps = {
| "onSendLink"
| "onSelectCollection"
| "onSelectPerson"
- | "publicAlbumsCredentials"
- | "collectionKey"
- | "onJoinAlbum"
- | "enableComment"
- | "enableJoin"
>;
/**
@@ -195,11 +188,6 @@ export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({
pendingFileSidebar,
pendingHighlightCommentID,
onPendingNavigationConsumed,
- publicAlbumsCredentials,
- collectionKey,
- onJoinAlbum,
- enableComment,
- enableJoin,
}) => {
const [openFileViewer, setOpenFileViewer] = useState(false);
const [currentIndex, setCurrentIndex] = useState(0);
@@ -404,11 +392,6 @@ export const FileListWithViewer: React.FC<FileListWithViewerProps> = ({
onSendLink,
onSelectCollection,
onSelectPerson,
- publicAlbumsCredentials,
- collectionKey,
- onJoinAlbum,
- enableComment,
- enableJoin,
}}
isCommentsFeatureEnabled
onTriggerRemotePull={handleTriggerRemotePull}
diff --git a/web/apps/photos/src/components/PublicAlbumSingleFileViewer.tsx b/web/apps/photos/src/components/PublicAlbumSingleFileViewer.tsx
deleted file mode 100644
index 3a9deb542c..0000000000
--- a/web/apps/photos/src/components/PublicAlbumSingleFileViewer.tsx
+++ /dev/null
@@ -1,852 +0,0 @@
-import CheckIcon from "@mui/icons-material/Check";
-import ContentCopyIcon from "@mui/icons-material/ContentCopy";
-import DownloadOutlinedIcon from "@mui/icons-material/DownloadOutlined";
-import FullscreenOutlinedIcon from "@mui/icons-material/FullscreenOutlined";
-import InfoOutlinedIcon from "@mui/icons-material/InfoOutlined";
-import MoreVertIcon from "@mui/icons-material/MoreVert";
-import ShareOutlinedIcon from "@mui/icons-material/ShareOutlined";
-import {
- Box,
- Button,
- CircularProgress,
- GlobalStyles,
- IconButton,
- Menu,
- MenuItem,
- Stack,
- styled,
- Typography,
-} from "@mui/material";
-import { EnteLogo } from "ente-base/components/EnteLogo";
-import { ActivityIndicator } from "ente-base/components/mui/ActivityIndicator";
-import { useBaseContext } from "ente-base/context";
-import type { PublicAlbumsCredentials } from "ente-base/http";
-import log from "ente-base/log";
-import type { AddSaveGroup } from "ente-gallery/components/utils/save-groups";
-import { FileViewer } from "ente-gallery/components/viewer/FileViewer";
-import { createPSRegisterElementIconHTML } from "ente-gallery/components/viewer/icons";
-import { downloadManager } from "ente-gallery/services/download";
-import { downloadAndSaveFiles } from "ente-gallery/services/save";
-import type { EnteFile } from "ente-media/file";
-import { fileFileName } from "ente-media/file-metadata";
-import { FileType } from "ente-media/file-type";
-import { Notification } from "ente-new/photos/components/Notification";
-import { t } from "i18next";
-import { useCallback, useEffect, useMemo, useState } from "react";
-import { getEnteURL } from "utils/public-album";
-
-interface PublicAlbumSingleFileViewerProps {
- file: EnteFile;
- publicAlbumsCredentials: PublicAlbumsCredentials;
- collectionKey: string;
- enableDownload: boolean;
- enableComment: boolean;
- enableJoin?: boolean;
- onJoinAlbum?: () => void;
- onVisualFeedback: () => void;
- onAddSaveGroup: AddSaveGroup;
-}
-
-const bodyClassName = "ente-public-single-file-viewer";
-interface LivePhotoControlsState {
- playAvailable: boolean;
- muteAvailable: boolean;
- isPlayOff: boolean;
- isMuteOff: boolean;
-}
-
-const inlineFileViewerIconPath = (name: "live" | "vol") =>
- createPSRegisterElementIconHTML(name).inner.replace(
- /\s+id="pswp__icn-[^"]+"/g,
- "",
- );
-
-const liveIconPath = inlineFileViewerIconPath("live");
-const volumeIconPath = inlineFileViewerIconPath("vol");
-
-/**
- * A dedicated public-album single-file viewer mode with a bespoke header/menu.
- *
- * This wraps the regular FileViewer but overlays its own controls.
- */
-export const PublicAlbumSingleFileViewer: React.FC<
- PublicAlbumSingleFileViewerProps
-> = ({
- file,
- publicAlbumsCredentials,
- collectionKey,
- enableDownload,
- enableComment,
- enableJoin,
- onJoinAlbum,
- onVisualFeedback,
- onAddSaveGroup,
-}) => {
- const { onGenericError } = useBaseContext();
- const [menuAnchorEl, setMenuAnchorEl] = useState<HTMLElement | null>(null);
- const [showCopiedMessage, setShowCopiedMessage] = useState(false);
- const [isPhotoSwipeUIVisible, setIsPhotoSwipeUIVisible] = useState(true);
- const [isPhotoSwipeContentLoading, setIsPhotoSwipeContentLoading] =
- useState(false);
- const isLivePhotoFile = file.metadata.fileType === FileType.livePhoto;
- const [livePhotoControls, setLivePhotoControls] =
- useState<LivePhotoControlsState>({
- playAvailable: false,
- muteAvailable: false,
- isPlayOff: true,
- isMuteOff: true,
- });
- const needsThumbnailPrime =
- file.metadata.fileType === FileType.image ||
- file.metadata.fileType === FileType.livePhoto;
- const needsOriginalPrime = needsThumbnailPrime;
- const [viewerFile, setViewerFile] = useState(file);
- const [primedFileID, setPrimedFileID] = useState<number | undefined>(() =>
- needsThumbnailPrime ? undefined : file.id,
- );
- const isViewerPrimed = !needsThumbnailPrime || primedFileID === file.id;
- const viewerFiles = useMemo(() => [viewerFile], [viewerFile]);
-
- useEffect(() => {
- document.body.classList.add(bodyClassName);
- return () => document.body.classList.remove(bodyClassName);
- }, []);
-
- useEffect(() => {
- if (
- file.id !== viewerFile.id ||
- file.collectionID !== viewerFile.collectionID ||
- file.updationTime !== viewerFile.updationTime
- ) {
- setViewerFile(file);
- }
- }, [
- file,
- file.collectionID,
- file.id,
- file.updationTime,
- viewerFile.collectionID,
- viewerFile.id,
- viewerFile.updationTime,
- ]);
-
- useEffect(() => {
- let classObserver: MutationObserver | undefined;
- let preloaderObserver: MutationObserver | undefined;
- let pswpElement: HTMLElement | null = null;
- let preloaderElement: HTMLElement | null = null;
-
- const updateVisibility = () => {
- setIsPhotoSwipeUIVisible(
- pswpElement?.classList.contains("pswp--ui-visible") ?? true,
- );
- };
-
- const updateLoading = () => {
- setIsPhotoSwipeContentLoading(
- preloaderElement?.classList.contains(
- "pswp__preloader--active",
- ) ?? false,
- );
- };
-
- const bindToPreloaderElement = () => {
- const next =
- pswpElement?.querySelector<HTMLElement>(".pswp__preloader");
- if (next === preloaderElement) return;
-
- preloaderObserver?.disconnect();
- preloaderObserver = undefined;
- preloaderElement = next ?? null;
-
- if (!preloaderElement) {
- setIsPhotoSwipeContentLoading(false);
- return;
- }
-
- preloaderObserver = new MutationObserver(updateLoading);
- preloaderObserver.observe(preloaderElement, {
- attributes: true,
- attributeFilter: ["class"],
- });
- updateLoading();
- };
-
- const bindToPhotoSwipeElement = () => {
- const next = document.querySelector<HTMLElement>(".pswp");
- if (next !== pswpElement) {
- classObserver?.disconnect();
- classObserver = undefined;
- pswpElement = next;
-
- if (!pswpElement) {
- preloaderObserver?.disconnect();
- preloaderObserver = undefined;
- preloaderElement = null;
- setIsPhotoSwipeUIVisible(true);
- setIsPhotoSwipeContentLoading(false);
- return;
- }
-
- classObserver = new MutationObserver(updateVisibility);
- classObserver.observe(pswpElement, {
- attributes: true,
- attributeFilter: ["class"],
- });
- updateVisibility();
- }
-
- bindToPreloaderElement();
- };
-
- const treeObserver = new MutationObserver(bindToPhotoSwipeElement);
- treeObserver.observe(document.body, { childList: true, subtree: true });
- bindToPhotoSwipeElement();
-
- return () => {
- treeObserver.disconnect();
- classObserver?.disconnect();
- preloaderObserver?.disconnect();
- };
- }, []);
-
- useEffect(() => {
- if (!isLivePhotoFile) {
- setLivePhotoControls({
- playAvailable: false,
- muteAvailable: false,
- isPlayOff: true,
- isMuteOff: true,
- });
- return;
- }
-
- let playButtonObserver: MutationObserver | undefined;
- let muteButtonObserver: MutationObserver | undefined;
- let playButton: HTMLButtonElement | null = null;
- let muteButton: HTMLButtonElement | null = null;
-
- const updateLivePhotoControls = () => {
- const nextState: LivePhotoControlsState = {
- playAvailable:
- !!playButton &&
- !playButton.classList.contains("pswp__hidden"),
- muteAvailable:
- !!muteButton &&
- !muteButton.classList.contains("pswp__hidden"),
- isPlayOff: playButton?.classList.contains("pswp-ente-off")
- ? true
- : false,
- isMuteOff: muteButton?.classList.contains("pswp-ente-off")
- ? true
- : false,
- };
-
- setLivePhotoControls((prev) =>
- prev.playAvailable === nextState.playAvailable &&
- prev.muteAvailable === nextState.muteAvailable &&
- prev.isPlayOff === nextState.isPlayOff &&
- prev.isMuteOff === nextState.isMuteOff
- ? prev
- : nextState,
- );
- };
-
- const observeButtonClassChanges = () => {
- const nextPlayButton = document.querySelector<HTMLButtonElement>(
- ".pswp .pswp__button--live",
- );
- if (nextPlayButton !== playButton) {
- playButtonObserver?.disconnect();
- playButtonObserver = undefined;
- playButton = nextPlayButton;
- if (playButton) {
- playButtonObserver = new MutationObserver(
- updateLivePhotoControls,
- );
- playButtonObserver.observe(playButton, {
- attributes: true,
- attributeFilter: ["class"],
- });
- }
- }
-
- const nextMuteButton = document.querySelector<HTMLButtonElement>(
- ".pswp .pswp__button--vol",
- );
- if (nextMuteButton !== muteButton) {
- muteButtonObserver?.disconnect();
- muteButtonObserver = undefined;
- muteButton = nextMuteButton;
- if (muteButton) {
- muteButtonObserver = new MutationObserver(
- updateLivePhotoControls,
- );
- muteButtonObserver.observe(muteButton, {
- attributes: true,
- attributeFilter: ["class"],
- });
- }
- }
-
- updateLivePhotoControls();
- };
-
- const treeObserver = new MutationObserver(observeButtonClassChanges);
- treeObserver.observe(document.body, { childList: true, subtree: true });
- observeButtonClassChanges();
-
- return () => {
- treeObserver.disconnect();
- playButtonObserver?.disconnect();
- muteButtonObserver?.disconnect();
- };
- }, [isLivePhotoFile]);
-
- useEffect(() => {
- if (!needsThumbnailPrime) {
- setPrimedFileID(file.id);
- return;
- }
- if (primedFileID === file.id) return;
-
- let isActive = true;
- void downloadManager
- .renderableThumbnailURL(file)
- .catch((error: unknown) =>
- log.warn(
- "Failed to prime thumbnail for public single-file viewer",
- error,
- ),
- )
- .finally(() => {
- if (isActive) setPrimedFileID(file.id);
- });
-
- return () => {
- isActive = false;
- };
- }, [file, file.id, needsThumbnailPrime, primedFileID]);
-
- useEffect(() => {
- if (!needsOriginalPrime) return;
-
- // Give thumbnail fetch a brief head-start, then warm the original.
- const prefetchTimer = window.setTimeout(() => {
- void downloadManager
- .renderableSourceURLs(file)
- .catch((error: unknown) =>
- log.warn(
- "Failed to prime original for public single-file viewer",
- error,
- ),
- );
- }, 120);
-
- return () => window.clearTimeout(prefetchTimer);
- }, [file, needsOriginalPrime]);
-
- const handleViewerClose = useCallback(() => {
- window.history.back();
- }, []);
-
- const handleMenuClose = useCallback(() => setMenuAnchorEl(null), []);
-
- const handleDownload = useCallback(
- (targetFile: EnteFile) =>
- downloadAndSaveFiles(
- [targetFile],
- fileFileName(targetFile),
- onAddSaveGroup,
- ),
- [onAddSaveGroup],
- );
-
- const handleShare = useCallback(async () => {
- handleMenuClose();
- const shareUrl = window.location.href;
- const isMobile = window.matchMedia("(width < 720px)").matches;
-
- if (isMobile && typeof navigator.share === "function") {
- try {
- await navigator.share({ text: shareUrl });
- return;
- } catch (error) {
- if (error instanceof Error && error.name === "AbortError") {
- return;
- }
- }
- }
-
- try {
- await navigator.clipboard.writeText(shareUrl);
- setShowCopiedMessage(true);
- window.setTimeout(() => setShowCopiedMessage(false), 2000);
- } catch (error) {
- onGenericError(error);
- }
- }, [handleMenuClose, onGenericError]);
-
- const canCopyAsPNG = useMemo(
- () =>
- enableDownload &&
- (file.metadata.fileType === FileType.image ||
- file.metadata.fileType === FileType.livePhoto),
- [enableDownload, file.metadata.fileType],
- );
-
- const handleCopyAsPNG = useCallback(async () => {
- handleMenuClose();
- if (!canCopyAsPNG) return;
-
- try {
- const imageElement =
- document.querySelector<HTMLImageElement>(
- ".pswp .pswp__item--active img.pswp__img",
- ) ??
- document.querySelector<HTMLImageElement>(".pswp img.pswp__img");
-
- const imageURL = imageElement?.currentSrc || imageElement?.src;
- if (!imageURL) return;
-
- await navigator.clipboard.write([
- new ClipboardItem({
- "image/png": createImagePNGBlob(imageURL),
- }),
- ]);
- onVisualFeedback();
- } catch (error) {
- onGenericError(error);
- }
- }, [canCopyAsPNG, handleMenuClose, onGenericError, onVisualFeedback]);
-
- const handleOpenInfo = useCallback(() => {
- handleMenuClose();
- document
- .querySelector<HTMLButtonElement>(".pswp .pswp__button--info")
- ?.click();
- }, [handleMenuClose]);
-
- const handleToggleFullscreen = useCallback(() => {
- handleMenuClose();
- void (
- document.fullscreenElement
- ? document.exitFullscreen()
- : document.body.requestFullscreen()
- ).catch(onGenericError);
- }, [handleMenuClose, onGenericError]);
-
- const handleTryEnte = useCallback(() => {
- window.location.href = getEnteURL();
- }, []);
-
- const handleToggleLivePhotoPlay = useCallback(() => {
- document
- .querySelector<HTMLButtonElement>(
- ".pswp .pswp__button--live:not(.pswp__hidden)",
- )
- ?.click();
- }, []);
-
- const handleToggleLivePhotoMute = useCallback(() => {
- document
- .querySelector<HTMLButtonElement>(
- ".pswp .pswp__button--vol:not(.pswp__hidden)",
- )
- ?.click();
- }, []);
-
- const topControlsVisible = isViewerPrimed && isPhotoSwipeUIVisible;
-
- useEffect(() => {
- if (!topControlsVisible) {
- setMenuAnchorEl(null);
- }
- }, [topControlsVisible]);
-
- return (
- <>
- <GlobalStyles
- styles={{
- [`body.${bodyClassName} .pswp-ente-public-album .pswp__counter`]:
- { display: "none !important" },
- [`body.${bodyClassName} .pswp-ente-public-album .pswp__button--zoom`]:
- { display: "none !important" },
- [`body.${bodyClassName} .pswp-ente-public-album .pswp__button--close`]:
- { display: "none !important" },
- [`body.${bodyClassName} .pswp-ente-public-album .pswp__button--more`]:
- { display: "none !important" },
- [`body.${bodyClassName} .pswp-ente-public-album .pswp__button--info`]:
- { display: "none !important" },
- [`body.${bodyClassName} .pswp-ente-public-album .pswp__button--ente-logo`]:
- { display: "none !important" },
- [`body.${bodyClassName} .pswp-ente-public-album .pswp__button--download`]:
- { display: "none !important" },
- [`body.${bodyClassName} .pswp-ente-public-album .pswp__button--live`]:
- { display: "none !important" },
- [`body.${bodyClassName} .pswp-ente-public-album .pswp__button--vol`]:
- { display: "none !important" },
- [`body.${bodyClassName} .pswp-ente-public-album .pswp__preloader`]:
- { display: "none !important" },
- }}
- />
- <FileViewer
- open
- onClose={handleViewerClose}
- files={viewerFiles}
- initialIndex={0}
- disableEscapeClose
- disableDownload={!enableDownload}
- onDownload={enableDownload ? handleDownload : undefined}
- onVisualFeedback={onVisualFeedback}
- publicAlbumsCredentials={publicAlbumsCredentials}
- shouldCloseOnBrowserBack={false}
- collectionKey={collectionKey}
- onJoinAlbum={onJoinAlbum}
- enableComment={enableComment}
- enableJoin={enableJoin}
- />
- {isViewerPrimed && (
- <>
- <Box
- sx={{
- position: "fixed",
- top: {
- xs: "calc(env(titlebar-area-height, 0px) * 0.4 + 12px)",
- sm: "calc(env(titlebar-area-height, 0px) * 0.4 + 40px)",
- },
- left: 0,
- right: 0,
- pl: { xs: 1.5, sm: 5.5 },
- pr: { xs: 0.5, sm: 4 },
- zIndex: (theme) => theme.zIndex.drawer,
- pointerEvents: "none",
- opacity: topControlsVisible ? 1 : 0,
- transform: topControlsVisible
- ? "translateY(0)"
- : "translateY(-8px)",
- transition:
- "opacity 220ms ease, transform 220ms ease",
- }}
- >
- <Stack
- direction="row"
- justifyContent="space-between"
- alignItems="center"
- sx={{
- pointerEvents: topControlsVisible
- ? "auto"
- : "none",
- }}
- >
- <Stack
- direction="row"
- alignItems="center"
- spacing={1.5}
- >
- <Box
- component="a"
- href="https://ente.com"
- target="_blank"
- rel="noopener noreferrer"
- sx={{
- color: "white",
- opacity: 0.85,
- lineHeight: 0,
- "& svg": {
- width: "auto",
- height: { xs: 15, sm: 19 },
- },
- "&:hover": { opacity: 1 },
- }}
- >
- <EnteLogo height={15} />
- </Box>
- {isPhotoSwipeContentLoading ? (
- <CircularProgress
- size={16}
- thickness={5}
- sx={{
- color: "rgb(255 255 255 / 0.85)",
- }}
- />
- ) : (
- isLivePhotoFile && (
- <Stack
- direction="row"
- alignItems="center"
- spacing={0.5}
- >
- <FileViewerStyleButton
- onClick={
- handleToggleLivePhotoPlay
- }
- disabled={
- !livePhotoControls.playAvailable
- }
- aria-label={t("live")}
- className={
- livePhotoControls.isPlayOff
- ? "pswp-ente-off"
- : undefined
- }
- >
- <svg
- viewBox="0 0 32 32"
- width="32"
- height="32"
- fill="currentColor"
- aria-hidden="true"
- dangerouslySetInnerHTML={{
- __html: liveIconPath,
- }}
- />
- </FileViewerStyleButton>
- <FileViewerStyleButton
- onClick={
- handleToggleLivePhotoMute
- }
- disabled={
- !livePhotoControls.muteAvailable
- }
- aria-label={t("audio")}
- className={
- livePhotoControls.isMuteOff
- ? "pswp-ente-off"
- : undefined
- }
- >
- <svg
- viewBox="0 0 32 32"
- width="32"
- height="32"
- fill="currentColor"
- aria-hidden="true"
- dangerouslySetInnerHTML={{
- __html: volumeIconPath,
- }}
- />
- </FileViewerStyleButton>
- </Stack>
- )
- )}
- </Stack>
- <Stack
- direction="row"
- alignItems="center"
- spacing={1}
- >
- <Button
- variant="contained"
- onClick={handleTryEnte}
- sx={{
- borderRadius: "16px",
- paddingBlock: "11px",
- paddingInline: "20px",
- minHeight: "unset",
- textTransform: "none",
- fontWeight: "medium",
- color: "#fff",
- backgroundColor: "#08C225",
- "&:hover": {
- color: "#fff",
- backgroundColor: "#07A820",
- },
- }}
- >
- {t("try_ente")}
- </Button>
- <IconButton
- onClick={(event) =>
- setMenuAnchorEl(event.currentTarget)
- }
- aria-label={t("more")}
- sx={{
- color: "white",
- width: 40,
- height: 40,
- p: 0.75,
- bgcolor: "rgba(0, 0, 0, 0.4)",
- "&:hover": {
- bgcolor: "rgba(0, 0, 0, 0.55)",
- },
- }}
- >
- <MoreVertIcon />
- </IconButton>
- </Stack>
- </Stack>
- </Box>
- <MoreMenu
- open={!!menuAnchorEl}
- anchorEl={menuAnchorEl}
- onClose={handleMenuClose}
- disableAutoFocusItem
- slotProps={{ paper: { sx: { mt: "10px" } } }}
- >
- {enableDownload && (
- <MoreMenuItem
- onClick={() => {
- handleMenuClose();
- void handleDownload(file);
- }}
- >
- <MoreMenuItemTitle>
- {t("download")}
- </MoreMenuItemTitle>
- <DownloadOutlinedIcon />
- </MoreMenuItem>
- )}
- <MoreMenuItem onClick={handleOpenInfo}>
- <MoreMenuItemTitle>{t("info")}</MoreMenuItemTitle>
- <InfoOutlinedIcon />
- </MoreMenuItem>
- <MoreMenuItem onClick={() => void handleShare()}>
- <MoreMenuItemTitle>
- {t("share_action")}
- </MoreMenuItemTitle>
- <ShareOutlinedIcon />
- </MoreMenuItem>
- {canCopyAsPNG && (
- <MoreMenuItem
- onClick={() => void handleCopyAsPNG()}
- >
- <MoreMenuItemTitle>
- {t("copy_as_png")}
- </MoreMenuItemTitle>
- <ContentCopyIcon
- sx={{ "&&": { fontSize: "18px" } }}
- />
- </MoreMenuItem>
- )}
- <MoreMenuItem onClick={handleToggleFullscreen}>
- <MoreMenuItemTitle>
- {t("go_fullscreen")}
- </MoreMenuItemTitle>
- <FullscreenOutlinedIcon />
- </MoreMenuItem>
- </MoreMenu>
- </>
- )}
- {!isViewerPrimed && (
- <Box
- sx={{
- position: "fixed",
- inset: 0,
- display: "flex",
- alignItems: "center",
- justifyContent: "center",
- backgroundColor: "black",
- zIndex: (theme) => theme.zIndex.modal + 2,
- }}
- >
- <ActivityIndicator />
- </Box>
- )}
- <Notification
- open={showCopiedMessage}
- onClose={() => setShowCopiedMessage(false)}
- horizontal="left"
- attributes={{
- color: "secondary",
- startIcon: <CheckIcon />,
- title: "Copied!",
- }}
- />
- </>
- );
-};
-
-const MoreMenu = styled(Menu)(
- ({ theme }) => `
- & .MuiPaper-root {
- background-color: ${theme.vars.palette.fixed.dark.background.paper};
- }
- & .MuiList-root {
- padding-block: 2px;
- }
-`,
-);
-
-const MoreMenuItem = styled(MenuItem)(
- ({ theme }) => `
- min-width: 210px;
- padding-block: 12px;
- min-height: auto;
- gap: 1;
- justify-content: space-between;
- align-items: center;
- color: rgba(255 255 255 / 0.85);
- &:hover {
- color: rgba(255 255 255 / 1);
- background-color: ${theme.vars.palette.fixed.dark.background.paper2}
- }
-
- .MuiSvgIcon-root {
- font-size: 20px;
- }
-`,
-);
-
-const MoreMenuItemTitle: React.FC<React.PropsWithChildren> = ({ children }) => (
- <Typography sx={{ fontWeight: "medium" }}>{children}</Typography>
-);
-
-const FileViewerStyleButton = styled("button")`
- width: 44px;
- height: 44px;
- min-width: 44px;
- padding: 0;
- margin: 0;
- border: 0;
- background: transparent;
- display: flex;
- align-items: center;
- justify-content: center;
- cursor: pointer;
- opacity: 0.85;
- -webkit-appearance: none;
- -webkit-touch-callout: none;
-
- &:hover,
- &:active,
- &:focus {
- transition: none;
- opacity: 1;
- }
-
- svg {
- display: block;
- fill: white;
- }
-
- &.pswp-ente-off svg {
- fill: rgb(255 255 255 / 0.6);
- }
-
- &:disabled {
- opacity: 0.3;
- cursor: default;
- }
-`;
-
-/**
- * Return an "image/png" blob derived from the given source URL.
- */
-const createImagePNGBlob = async (imageURL: string): Promise<Blob> =>
- new Promise((resolve, reject) => {
- const image = new Image();
- image.onload = () => {
- const canvas = document.createElement("canvas");
- canvas.width = image.width;
- canvas.height = image.height;
- canvas.getContext("2d")!.drawImage(image, 0, 0);
- canvas.toBlob(
- (blob) =>
- blob ? resolve(blob) : reject(new Error("toBlob failed")),
- "image/png",
- );
- };
- image.onerror = reject;
- image.src = imageURL;
- });
diff --git a/web/apps/photos/src/components/Upload.tsx b/web/apps/photos/src/components/Upload.tsx
index c274688d9f..cf152a1906 100644
--- a/web/apps/photos/src/components/Upload.tsx
+++ b/web/apps/photos/src/components/Upload.tsx
@@ -26,14 +26,12 @@ import { DialogCloseIconButton } from "ente-base/components/mui/DialogCloseIconB
import { FocusVisibleButton } from "ente-base/components/mui/FocusVisibleButton";
import { RowButton } from "ente-base/components/RowButton";
import { SingleInputDialog } from "ente-base/components/SingleInputDialog";
-import { useIsTouchscreen } from "ente-base/components/utils/hooks";
import {
useModalVisibility,
type ModalVisibilityProps,
} from "ente-base/components/utils/modal";
import { useBaseContext } from "ente-base/context";
import { basename, dirname, joinPath } from "ente-base/file-name";
-import type { PublicAlbumsCredentials } from "ente-base/http";
import log from "ente-base/log";
import type { CollectionMapping, Electron, ZipItem } from "ente-base/types/ipc";
import { type UploadTypeSelectorIntent } from "ente-gallery/components/Upload";
@@ -54,11 +52,6 @@ import {
} from "ente-gallery/services/upload/upload-service";
import { CollectionSubType, type Collection } from "ente-media/collection";
import type { EnteFile } from "ente-media/file";
-import { UploaderNameInput } from "ente-new/albums/components/UploaderNameInput";
-import {
- savedPublicCollectionUploaderName,
- savePublicCollectionUploaderName,
-} from "ente-new/albums/services/public-albums-fdb";
import { CollectionMappingChoice } from "ente-new/photos/components/CollectionMappingChoice";
import type { CollectionSelectorAttributes } from "ente-new/photos/components/CollectionSelector";
import type { RemotePullOpts } from "ente-new/photos/components/gallery";
@@ -91,25 +84,11 @@ import { CanvasReadbackBlockedDialog } from "./CanvasReadbackBlockedDialog";
import { UploadProgress } from "./UploadProgress";
interface UploadProps {
- /**
- * The logged in user, if any.
- *
- * This is only expected to be present when we're running it the context of
- * the photos app, where there is a logged in user. When used by the public
- * albums app, this prop can be omitted.
- */
+ /** The logged in user, if any. */
user?: LocalUser;
- /**
- * The {@link PublicAlbumsCredentials} to use, if any.
- *
- * These are expected to be set if we are in the context of the public
- * albums app, and should be undefined when we're in the photos app context.
- */
- publicAlbumsCredentials?: PublicAlbumsCredentials;
isFirstUpload?: boolean;
uploadTypeSelectorView: boolean;
dragAndDropFiles: File[];
- uploadCollection?: Collection;
uploadTypeSelectorIntent: UploadTypeSelectorIntent;
activeCollection?: Collection;
closeUploadTypeSelector: () => void;
@@ -132,11 +111,8 @@ interface UploadProps {
* Specifically, this is used prior to creating a new album, to obtain
* (potential) existing albums from remote so that they can be matched by
* name if needed.
- *
- * This functionality is not needed during uploads to a public album, so
- * this property is optional; the public albums code need not provide it.
*/
- onRemoteFilesPull?: () => Promise<void>;
+ onRemoteFilesPull: () => Promise<void>;
/**
* Show the collection selector with the given {@link attributes}.
*/
@@ -153,12 +129,7 @@ interface UploadProps {
* @param file The newly uploaded file.
*/
onUploadFile: (file: EnteFile) => void;
- /**
- * Called when the plan selection modal should be shown.
- *
- * It is optional because {@link Upload} is also used by the public albums
- * app, where the scenario requiring this will not arise.
- */
+ /** Called when the plan selection modal should be shown. */
onShowPlanSelector?: () => void;
/**
* Called when the upload failed because the user's session has expired, and
@@ -181,7 +152,6 @@ type UploadType = "files" | "folders" | "zips";
*/
export const Upload: React.FC<UploadProps> = ({
user,
- publicAlbumsCredentials,
isFirstUpload,
dragAndDropFiles,
onRemotePull,
@@ -215,7 +185,6 @@ export const Upload: React.FC<UploadProps> = ({
const [percentComplete, setPercentComplete] = useState(0);
const [hasLivePhotos, setHasLivePhotos] = useState(false);
const [prefilledNewAlbumName, setPrefilledNewAlbumName] = useState("");
- const [uploaderName, setUploaderName] = useState("");
const [openCollectionMappingChoice, setOpenCollectionMappingChoice] =
useState(false);
@@ -226,10 +195,6 @@ export const Upload: React.FC<UploadProps> = ({
show: showNewAlbumNameInput,
props: newAlbumNameInputVisibilityProps,
} = useModalVisibility();
- const {
- show: showUploaderNameInput,
- props: uploaderNameInputVisibilityProps,
- } = useModalVisibility();
/**
* {@link File}s that the user drag-dropped or selected for uploads (web).
@@ -377,11 +342,6 @@ export const Upload: React.FC<UploadProps> = ({
uploadRunning.current = false;
};
- const handleUploaderNameInputClose = () => {
- uploaderNameInputVisibilityProps.onClose();
- uploadRunning.current = false;
- };
-
useEffect(() => {
uploadManager.init(
{
@@ -397,7 +357,6 @@ export const Upload: React.FC<UploadProps> = ({
setUploadProgressView,
},
onUploadFile,
- publicAlbumsCredentials,
);
if (uploadManager.isUploadRunning()) {
@@ -427,7 +386,7 @@ export const Upload: React.FC<UploadProps> = ({
setDesktopZipItems(zipItems);
});
}
- }, [publicAlbumsCredentials]);
+ }, []);
// Handle selected files when user selects files for upload through the open
// file / open folder selection dialog, or drag-and-drops them.
@@ -553,84 +512,66 @@ export const Upload: React.FC<UploadProps> = ({
selectedUploadType.current = undefined;
props.setLoading(false);
- (async () => {
- if (publicAlbumsCredentials) {
- setUploaderName(
- (await savedPublicCollectionUploaderName(
- publicAlbumsCredentials.accessToken,
- )) ?? "",
+ if (isPendingDesktopUpload.current) {
+ isPendingDesktopUpload.current = false;
+ if (pendingDesktopUploadCollectionName.current) {
+ // Include hidden collections so watch folder syncs add
+ // files to existing hidden albums instead of creating new
+ // visible ones
+ uploadFilesToNewCollections(
+ "root",
+ pendingDesktopUploadCollectionName.current,
+ true,
);
- showUploaderNameInput();
- return;
- }
-
- if (isPendingDesktopUpload.current) {
- isPendingDesktopUpload.current = false;
- if (pendingDesktopUploadCollectionName.current) {
- // Include hidden collections so watch folder syncs add
- // files to existing hidden albums instead of creating new
- // visible ones
- uploadFilesToNewCollections(
- "root",
- pendingDesktopUploadCollectionName.current,
- true,
- );
- pendingDesktopUploadCollectionName.current = undefined;
- } else {
- uploadFilesToNewCollections("parent", undefined, true);
- }
- return;
+ pendingDesktopUploadCollectionName.current = undefined;
+ } else {
+ uploadFilesToNewCollections("parent", undefined, true);
}
+ return;
+ }
- if (electron && _selectedUploadType == "zips") {
- uploadFilesToNewCollections("parent");
- return;
- }
+ if (electron && _selectedUploadType == "zips") {
+ uploadFilesToNewCollections("parent");
+ return;
+ }
- if (isFirstUpload && !importSuggestion.rootFolderName) {
- importSuggestion.rootFolderName = t(
- "autogenerated_first_album_name",
- );
- }
+ if (isFirstUpload && !importSuggestion.rootFolderName) {
+ importSuggestion.rootFolderName = t(
+ "autogenerated_first_album_name",
+ );
+ }
- if (isDragAndDrop.current) {
- isDragAndDrop.current = false;
- if (
- props.activeCollection &&
- props.activeCollection.owner.id == user?.id
- ) {
- uploadFilesToExistingCollection(props.activeCollection);
- return;
- }
+ if (isDragAndDrop.current) {
+ isDragAndDrop.current = false;
+ if (
+ props.activeCollection &&
+ props.activeCollection.owner.id == user?.id
+ ) {
+ uploadFilesToExistingCollection(props.activeCollection);
+ return;
}
+ }
- // eslint-disable-next-line @typescript-eslint/no-empty-function
- let showNextModal = () => {};
- if (importSuggestion.hasNestedFolders) {
- showNextModal = () => setOpenCollectionMappingChoice(true);
- } else {
- showNextModal = () => {
- setPrefilledNewAlbumName(importSuggestion.rootFolderName);
- showNewAlbumNameInput();
- };
- }
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
+ let showNextModal = () => {};
+ if (importSuggestion.hasNestedFolders) {
+ showNextModal = () => setOpenCollectionMappingChoice(true);
+ } else {
+ showNextModal = () => {
+ setPrefilledNewAlbumName(importSuggestion.rootFolderName);
+ showNewAlbumNameInput();
+ };
+ }
- onOpenCollectionSelector?.({
- action: "upload",
- activeCollectionID: props.activeCollection?.id,
- showHiddenCollections: props.isInHiddenSection,
- onSelectCollection: uploadFilesToExistingCollection,
- onCreateCollection: showNextModal,
- onCancel: handleCollectionSelectorCancel,
- });
- })();
- }, [
- publicAlbumsCredentials,
- webFiles,
- desktopFiles,
- desktopFilePaths,
- desktopZipItems,
- ]);
+ onOpenCollectionSelector?.({
+ action: "upload",
+ activeCollectionID: props.activeCollection?.id,
+ showHiddenCollections: props.isInHiddenSection,
+ onSelectCollection: uploadFilesToExistingCollection,
+ onCreateCollection: showNextModal,
+ onCancel: handleCollectionSelectorCancel,
+ });
+ }, [webFiles, desktopFiles, desktopFilePaths, desktopZipItems]);
const preCollectionCreationAction = () => {
onCloseCollectionSelector?.();
@@ -639,10 +580,7 @@ export const Upload: React.FC<UploadProps> = ({
setUploadProgressView(true);
};
- const uploadFilesToExistingCollection = async (
- collection: Collection,
- uploaderName?: string,
- ) => {
+ const uploadFilesToExistingCollection = async (collection: Collection) => {
preCollectionCreationAction();
const uploadItemsWithCollection = uploadItemsAndPaths.current.map(
([uploadItem, path], index) => ({
@@ -652,11 +590,7 @@ export const Upload: React.FC<UploadProps> = ({
collectionID: collection.id,
}),
);
- await waitInQueueAndUploadFiles(
- uploadItemsWithCollection,
- [collection],
- uploaderName,
- );
+ await waitInQueueAndUploadFiles(uploadItemsWithCollection, [collection]);
uploadItemsAndPaths.current = [];
};
@@ -687,7 +621,7 @@ export const Upload: React.FC<UploadProps> = ({
}
const collections: Collection[] = [];
try {
- await onRemoteFilesPull!();
+ await onRemoteFilesPull();
// When uploading to hidden section (createHidden), only search
// hidden collections. When syncing from watch folders
// (includeHiddenCollections), search all collections so files go
@@ -732,16 +666,11 @@ export const Upload: React.FC<UploadProps> = ({
const waitInQueueAndUploadFiles = async (
uploadItemsWithCollection: UploadItemWithCollection[],
collections: Collection[],
- uploaderName?: string,
) => {
const currentPromise = currentUploadPromise.current;
currentUploadPromise.current = (async () => {
if (currentPromise) await currentPromise;
- return uploadFiles(
- uploadItemsWithCollection,
- collections,
- uploaderName,
- );
+ return uploadFiles(uploadItemsWithCollection, collections);
})();
await currentUploadPromise.current;
};
@@ -763,7 +692,6 @@ export const Upload: React.FC<UploadProps> = ({
const uploadFiles = async (
uploadItemsWithCollection: UploadItemWithCollection[],
collections: Collection[],
- uploaderName?: string,
) => {
try {
preUploadAction();
@@ -783,7 +711,6 @@ export const Upload: React.FC<UploadProps> = ({
const wereFilesProcessed = await uploadManager.uploadItems(
uploadItemsWithCollection,
collections,
- uploaderName,
);
if (!wereFilesProcessed) closeUploadProgress();
if (isDesktop) {
@@ -809,9 +736,8 @@ export const Upload: React.FC<UploadProps> = ({
log.info("Retrying failed uploads");
const { items, collections, parsedMetadataJSONMap } =
uploadManager.failedItemState();
- const uploaderName = uploadManager.getUploaderName();
await preUploadAction(parsedMetadataJSONMap);
- await uploadManager.uploadItems(items, collections, uploaderName);
+ await uploadManager.uploadItems(items, collections);
} catch (e) {
log.error("Retrying failed uploads failed", e);
closeUploadProgress();
@@ -891,20 +817,6 @@ export const Upload: React.FC<UploadProps> = ({
}
};
- const handlePublicUpload = (uploaderName: string) => {
- savePublicCollectionUploaderName(
- publicAlbumsCredentials!.accessToken,
- uploaderName,
- );
-
- // Do not keep the uploader name input dialog open while the upload is
- // progressing (the upload progress indicator will take out now).
- void uploadFilesToExistingCollection(
- props.uploadCollection!,
- uploaderName,
- );
- };
-
const handleCollectionMappingSelect = (mapping: CollectionMapping) =>
uploadFilesToNewCollections(
mapping,
@@ -931,7 +843,6 @@ export const Upload: React.FC<UploadProps> = ({
<UploadTypeSelector
open={props.uploadTypeSelectorView}
onClose={props.closeUploadTypeSelector}
- publicAlbumsCredentials={publicAlbumsCredentials}
intent={props.uploadTypeSelectorIntent}
pendingUploadType={
isInputPending ? selectedUploadType.current : undefined
@@ -963,13 +874,6 @@ export const Upload: React.FC<UploadProps> = ({
submitButtonTitle={t("create")}
onSubmit={uploadToSingleNewCollection}
/>
- <UploaderNameInput
- open={uploaderNameInputVisibilityProps.open}
- onClose={handleUploaderNameInputClose}
- uploaderName={uploaderName}
- uploadFileCount={uploadItemsAndPaths.current.length}
- onSubmit={handlePublicUpload}
- />
</>
);
};
@@ -1188,7 +1092,7 @@ type UploadTypeSelectorProps = ModalVisibilityProps & {
* Called when the user selects one of the options.
*/
onSelect: (type: UploadType) => void;
-} & Pick<UploadProps, "publicAlbumsCredentials">;
+};
/**
* Request the user to specify which type of file / folder / zip it is that they
@@ -1202,22 +1106,10 @@ type UploadTypeSelectorProps = ModalVisibilityProps & {
const UploadTypeSelector: React.FC<UploadTypeSelectorProps> = ({
open,
onClose,
- publicAlbumsCredentials,
intent,
pendingUploadType,
onSelect,
}) => {
- // Directly show the file selector for the public albums app on likely
- // mobile devices.
- const directlyShowUploadFiles = useIsTouchscreen();
-
- useEffect(() => {
- if (open && directlyShowUploadFiles && publicAlbumsCredentials) {
- onSelect("files");
- onClose();
- }
- }, [open, publicAlbumsCredentials]);
-
const handleClose: DialogProps["onClose"] = () => {
// Disable backdrop clicks and esc keypresses if a selection is pending
// processing so that the user doesn't inadvertently close the dialog.
diff --git a/web/apps/photos/src/hooks/useJoinAlbum.ts b/web/apps/photos/src/hooks/useJoinAlbum.ts
deleted file mode 100644
index 36d9291816..0000000000
--- a/web/apps/photos/src/hooks/useJoinAlbum.ts
+++ /dev/null
@@ -1,146 +0,0 @@
-import type { PublicAlbumsCredentials } from "ente-base/http";
-import { albumsAppOrigin, photosAppOrigin } from "ente-base/origins";
-import type { Collection } from "ente-media/collection";
-
-export interface UseJoinAlbumProps {
- /** Collection to join */
- publicCollection?: Collection;
- /** Access token for the public link */
- accessToken?: string;
- /** Collection key from URL (base64 encoded) */
- collectionKey?: string;
- /** Credentials ref for JWT token access */
- credentials?: React.RefObject<PublicAlbumsCredentials | undefined>;
-}
-
-export interface UseJoinAlbumReturn {
- /** Handler for join album action */
- handleJoinAlbum: () => void;
-}
-
-/**
- * Build the web app redirect URL for joining an album.
- */
-const buildWebRedirectURL = (
- accessToken: string,
- collectionId: number,
- currentHash: string,
- jwtToken?: string,
-): string => {
- const webAppURL = photosAppOrigin();
- const hashSuffix = jwtToken ? `&jwt=${encodeURIComponent(jwtToken)}` : "";
- return `${webAppURL}/?joinAlbum=${accessToken}&collectionId=${collectionId}#${currentHash}${hashSuffix}`;
-};
-
-/**
- * Handle the fallback flow when the native app doesn't open.
- * Redirects to web app with all join context in the URL.
- */
-const handleWebFallback = (
- accessToken: string,
- collectionId: number,
- currentHash: string,
- jwtToken?: string,
-): void => {
- // Redirect to web app with joinAlbum parameter
- // The URL contains all necessary context (token, collectionId, JWT, hash) which will be
- // stored on web.ente.io after the domain transition
- const redirectURL = buildWebRedirectURL(
- accessToken,
- collectionId,
- currentHash,
- jwtToken,
- );
- window.location.href = redirectURL;
-};
-
-/**
- * Attempt to open the native app via deep link, with fallback to web.
- * Returns a cleanup function to clear the timeout if needed.
- */
-const tryDeepLinkWithFallback = (
- deepLinkURL: string,
- fallbackFn: () => void | Promise<void>,
- timeoutMs = 2500,
-): (() => void) => {
- let appOpened = false;
-
- // Track visibility changes - app opening will hide the page
- const onVisibilityChange = () => {
- if (document.visibilityState === "hidden") {
- appOpened = true;
- }
- };
-
- // Track page hide - more reliable on some Android browsers
- const onPageHide = () => {
- appOpened = true;
- };
-
- document.addEventListener("visibilitychange", onVisibilityChange);
- window.addEventListener("pagehide", onPageHide);
-
- // Try to open the app using the deep link
- // Use assign() instead of href for better compatibility with iOS Safari/PWAs
- window.location.assign(deepLinkURL);
-
- // Set a timeout to check if the app opened
- const timeoutId = setTimeout(() => {
- if (!appOpened) {
- void fallbackFn();
- }
- cleanup();
- }, timeoutMs);
-
- const cleanup = () => {
- clearTimeout(timeoutId);
- document.removeEventListener("visibilitychange", onVisibilityChange);
- window.removeEventListener("pagehide", onPageHide);
- };
-
- // Return cleanup function
- return cleanup;
-};
-
-/**
- * Custom hook that provides join album logic and handlers.
- * Components can use this hook and apply their own button styling.
- */
-export const useJoinAlbum = ({
- publicCollection,
- accessToken,
- collectionKey,
- credentials,
-}: UseJoinAlbumProps): UseJoinAlbumReturn => {
- const handleJoinAlbum = () => {
- if (!publicCollection || !accessToken || !collectionKey) {
- return;
- }
-
- // Get the original hash directly from the current URL
- const currentHash = window.location.hash.slice(1);
- const jwtToken = credentials?.current?.accessTokenJWT;
- const collectionId = publicCollection.id;
-
- // Create fallback function for mobile deep linking
- const fallbackToWeb = () => {
- handleWebFallback(accessToken, collectionId, currentHash, jwtToken);
- };
-
- // Check if on Android and try deep link with custom scheme with action=join parameter.
- // Skip deep linking on iOS - custom URL schemes show an error
- // dialog when the app isn't installed. On iOS Safari, if the photos app
- // is installed, a banner already appears at the top prompting to open in app.
- if (navigator.userAgent.includes("Android")) {
- const albumsHost = new URL(albumsAppOrigin()).host;
- const deepLinkURL = `ente://${albumsHost}/?action=join&t=${encodeURIComponent(accessToken)}#${currentHash}`;
-
- tryDeepLinkWithFallback(deepLinkURL, fallbackToWeb);
- } else {
- // Desktop and iOS: use the standard web flow directly
- handleWebFallback(accessToken, collectionId, currentHash, jwtToken);
- }
- };
-
- return { handleJoinAlbum };
-};
diff --git a/web/apps/photos/src/services/upload-manager.ts b/web/apps/photos/src/services/upload-manager.ts
index 76ba4f5c86..edf2fa5f2b 100644
--- a/web/apps/photos/src/services/upload-manager.ts
+++ b/web/apps/photos/src/services/upload-manager.ts
@@ -5,7 +5,6 @@ import { isDesktop } from "ente-base/app";
import { createComlinkCryptoWorker } from "ente-base/crypto";
import { type CryptoWorker } from "ente-base/crypto/worker";
import { lowercaseExtension, nameAndExtension } from "ente-base/file-name";
-import type { PublicAlbumsCredentials } from "ente-base/http";
import log from "ente-base/log";
import { ComlinkWorker } from "ente-base/worker/comlink-worker";
import {
@@ -39,7 +38,6 @@ import {
} from "ente-media/file-metadata";
import { FileType } from "ente-media/file-type";
import { potentialFileTypeFromExtension } from "ente-media/live-photo";
-import { savedPublicCollectionFiles } from "ente-new/albums/services/public-albums-fdb";
import { computeNormalCollectionFilesFromSaved } from "ente-new/photos/services/file";
import { indexNewUpload } from "ente-new/photos/services/ml";
import { wait } from "ente-utils/promise";
@@ -262,8 +260,6 @@ class UploadManager {
private onUploadFile: ((file: EnteFile) => void) | undefined;
private collections = new Map<number, Collection>();
private uploadInProgress = false;
- private publicAlbumsCredentials: PublicAlbumsCredentials | undefined;
- private uploaderName: string | undefined;
/**
* When `true`, then the next call to {@link abortIfCancelled} will throw.
*
@@ -276,12 +272,10 @@ class UploadManager {
public init(
progressUpdater: ProgressUpdater,
onUploadFile: (file: EnteFile) => void,
- publicAlbumsCredentials: PublicAlbumsCredentials | undefined,
) {
this.uiService.init(progressUpdater);
- UploadService.init(publicAlbumsCredentials);
+ UploadService.init(undefined);
this.onUploadFile = onUploadFile;
- this.publicAlbumsCredentials = publicAlbumsCredentials;
}
logout() {
@@ -300,7 +294,6 @@ class UploadManager {
this.failedItems = [];
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
this.parsedMetadataJSONMap = parsedMetadataJSONMap ?? new Map();
- this.uploaderName = undefined;
this.shouldUploadBeCancelled = false;
this.uiService.reset();
@@ -333,14 +326,12 @@ class UploadManager {
public async uploadItems(
itemsWithCollection: UploadItemWithCollection[],
collections: Collection[],
- uploaderName?: string,
) {
if (this.uploadInProgress)
throw new Error("Cannot run multiple uploads at once");
log.info(`Uploading ${itemsWithCollection.length} files`);
this.uploadInProgress = true;
- this.uploaderName = uploaderName;
const logInterval = setInterval(logAboutMemoryPressureIfNeeded, 1000);
@@ -443,15 +434,9 @@ class UploadManager {
};
private async updateExistingFilesAndCollections(collections: Collection[]) {
- if (this.publicAlbumsCredentials) {
- this.existingFiles = await savedPublicCollectionFiles(
- this.publicAlbumsCredentials.accessToken,
- );
- } else {
- const files = await computeNormalCollectionFilesFromSaved();
- const userID = ensureLocalUser().id;
- this.existingFiles = files.filter((file) => file.ownerID == userID);
- }
+ const files = await computeNormalCollectionFilesFromSaved();
+ const userID = ensureLocalUser().id;
+ this.existingFiles = files.filter((file) => file.ownerID == userID);
this.collections = new Map(
collections.map((collection) => [collection.id, collection]),
);
@@ -503,7 +488,6 @@ class UploadManager {
const uiService = this.uiService;
const uploadContext = {
isCFUploadProxyDisabled: shouldDisableCFUploadProxy(),
- publicAlbumsCredentials: this.publicAlbumsCredentials,
abortIfCancelled: this.abortIfCancelled.bind(this),
updateUploadProgress:
uiService.updateUploadProgress.bind(uiService),
@@ -523,7 +507,7 @@ class UploadManager {
const uploadResult = await upload(
uploadableItem,
- this.uploaderName,
+ undefined,
this.existingFiles,
this.parsedMetadataJSONMap,
worker,
@@ -604,10 +588,6 @@ class UploadManager {
};
}
- public getUploaderName() {
- return this.uploaderName;
- }
-
private updateExistingFiles(file: EnteFile) {
this.existingFiles.push(file);
this.onUploadFile!(file);
diff --git a/web/apps/photos/src/styles/photoswipe.css b/web/apps/photos/src/styles/photoswipe.css
index 6ca38ba76c..fa58740528 100644
--- a/web/apps/photos/src/styles/photoswipe.css
+++ b/web/apps/photos/src/styles/photoswipe.css
@@ -110,10 +110,6 @@
line-height: 20px;
}
-.pswp-ente-public-album .pswp__button--ente-logo {
- display: none;
-}
-
@media (width >= 450px) {
.pswp-ente .pswp__counter {
margin-top: 22px;
@@ -199,36 +195,6 @@
margin-right: -2px;
}
- .pswp-ente-public-album
- .pswp__top-bar
- .pswp__button:not(.pswp__button--ente-logo):not(.pswp__button--zoom) {
- margin-top: 1px;
- }
-
- .pswp-ente-public-album .pswp__counter,
- .pswp-ente-public-album .pswp__button--zoom {
- display: none;
- }
-
- .pswp-ente-public-album .pswp__button--ente-logo {
- display: flex;
- align-items: center;
- justify-content: center;
- margin-top: 21.5px;
- margin-inline-start: 4px;
- margin-inline-end: 0;
- width: auto;
- min-width: 0;
- padding-inline: 0;
- height: 20px;
- color: rgb(255 255 255 / 0.85);
- }
-
- .pswp-ente-public-album .pswp__button--ente-logo .pswp__ente-logo-svg {
- display: block;
- height: 15px;
- width: auto;
- }
}
@media (width < 350px) {
@@ -244,9 +210,6 @@
margin-right: -4px;
}
- .pswp-ente-public-album .pswp__button--ente-logo {
- margin-inline-start: 2px;
- }
}
/* Caption styling */
diff --git a/web/apps/photos/src/utils/public-album.ts b/web/apps/photos/src/utils/public-album.ts
deleted file mode 100644
index c1c662c554..0000000000
--- a/web/apps/photos/src/utils/public-album.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-/**
- * Get the destination URL for "Try Ente" actions in public albums.
- */
-export const getEnteURL = (): string => "https://ente.com/get";
diff --git a/web/packages/gallery/services/upload/upload-service.ts b/web/packages/gallery/services/upload/upload-service.ts
index bdada5d2ae..4439f1f97e 100644
--- a/web/packages/gallery/services/upload/upload-service.ts
+++ b/web/packages/gallery/services/upload/upload-service.ts
@@ -682,7 +682,7 @@ interface UploadContext {
* credentials for the logged in user, as happens when we're running in the
* context of the photos app).
*/
- publicAlbumsCredentials: PublicAlbumsCredentials | undefined;
+ publicAlbumsCredentials?: PublicAlbumsCredentials;
/**
* A function that the upload sequence should use to periodically check in
* and see if the upload has been cancelled by the user.