Skip to content

armgit / ente

Public Imported from GitHub
0

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

Use shouldOnlyServeAlbumsApp for public album detection in viewer

Anand Baburajan5d43d3c617c3
diff --git a/web/packages/gallery/components/viewer/CommentsSidebar.tsx b/web/packages/gallery/components/viewer/CommentsSidebar.tsx
index 1a709046d1..e6522d291c 100644
--- a/web/packages/gallery/components/viewer/CommentsSidebar.tsx
+++ b/web/packages/gallery/components/viewer/CommentsSidebar.tsx
@@ -15,6 +15,7 @@ import {
import { type ModalVisibilityProps } from "ente-base/components/utils/modal";
import type { PublicAlbumsCredentials } from "ente-base/http";
import log from "ente-base/log";
+import { shouldOnlyServeAlbumsApp } from "ente-base/origins";
import { downloadManager } from "ente-gallery/services/download";
import { getAvatarColor } from "ente-gallery/utils/avatar-colors";
import type { EnteFile } from "ente-media/file";
@@ -653,10 +654,8 @@ export const CommentsSidebar: React.FC<CommentsSidebarProps> = ({
return fileNormalCollectionIDs?.get(file.id) ?? [];
}, [file, fileNormalCollectionIDs]);
- // Check if this is a public album (has ?t=... in URL)
- const isPublicAlbum =
- typeof window !== "undefined" &&
- new URLSearchParams(window.location.search).has("t");
+ // Check if this is a public album
+ const isPublicAlbum = shouldOnlyServeAlbumsApp;
// Build collection info list with comment counts and cover files (shared albums only)
const collectionsInfo = useMemo((): CollectionInfo[] => {
diff --git a/web/packages/gallery/components/viewer/FileViewer.tsx b/web/packages/gallery/components/viewer/FileViewer.tsx
index 871074fb96..805dabf164 100644
--- a/web/packages/gallery/components/viewer/FileViewer.tsx
+++ b/web/packages/gallery/components/viewer/FileViewer.tsx
@@ -33,6 +33,7 @@ import { lowercaseExtension } from "ente-base/file-name";
import type { PublicAlbumsCredentials } from "ente-base/http";
import { formattedListJoin, ut } from "ente-base/i18n";
import log from "ente-base/log";
+import { shouldOnlyServeAlbumsApp } from "ente-base/origins";
import {
FileInfo,
type FileInfoExif,
@@ -701,17 +702,11 @@ export const FileViewer: React.FC<FileViewerProps> = ({
activeAnnotatedFileRef.current = activeAnnotatedFile;
// Called when the like button (heart) is clicked.
- // - If public album (has ?t=): toggle like (unlike if already liked, else show modal)
+ // - If public album: toggle like (unlike if already liked, else show modal)
// - If gallery view: show album selector (like) OR unlike selector/direct delete
// - If collection view: toggle like in that collection
const handleLikeClick = useCallback(() => {
- const searchParams =
- typeof window !== "undefined"
- ? new URLSearchParams(window.location.search)
- : new URLSearchParams();
- const isPublicAlbum = searchParams.has("t");
-
- if (isPublicAlbum) {
+ if (shouldOnlyServeAlbumsApp) {
const file = activeAnnotatedFileRef.current?.file;
if (!file || !publicAlbumsCredentials) {
setOpenPublicLikeModal(true);