Skip to content

armgit / ente

Public Imported from GitHub
0

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

[web][photos] Always show Get Ente button on public albums when join is disabled

Anand Baburajanb116abbe0d53
diff --git a/web/apps/photos/src/components/TripLayout/MobileNavBar.tsx b/web/apps/photos/src/components/TripLayout/MobileNavBar.tsx
index 9f556c4d53..b0aa109e4b 100644
--- a/web/apps/photos/src/components/TripLayout/MobileNavBar.tsx
+++ b/web/apps/photos/src/components/TripLayout/MobileNavBar.tsx
@@ -12,7 +12,7 @@ import { Notification } from "ente-new/photos/components/Notification";
import { useJoinAlbum } from "hooks/useJoinAlbum";
import { t } from "i18next";
import { useState } from "react";
-import { getSignUpOrInstallURL } from "utils/public-album";
+import { getEnteURL } from "utils/public-album";
interface MobileNavBarProps {
onAddPhotos?: () => void;
@@ -69,22 +69,6 @@ export const MobileNavBar: React.FC<MobileNavBarProps> = ({
}
};
- const handleSignUpOrInstall = () => {
- if (typeof window !== "undefined") {
- window.open(
- getSignUpOrInstallURL(isTouchscreen),
- "_blank",
- "noopener",
- );
- }
- };
-
- const buttonText = enableJoin
- ? t("join_album")
- : isTouchscreen
- ? t("install")
- : t("sign_up");
-
return (
<>
<MobileNavContainer>
@@ -99,7 +83,18 @@ export const MobileNavBar: React.FC<MobileNavBarProps> = ({
{onShowFeed && (
<MobileNavButton onClick={onShowFeed}>
- <FeedIcon />
+ <Box
+ sx={{
+ width: 16,
+ height: 16,
+ display: "flex",
+ alignItems: "center",
+ justifyContent: "center",
+ "& svg": { width: "100%", height: "100%" },
+ }}
+ >
+ <FeedIcon />
+ </Box>
</MobileNavButton>
)}
@@ -119,17 +114,20 @@ export const MobileNavBar: React.FC<MobileNavBarProps> = ({
</MobileNavButton>
)}
- {(!onAddPhotos || enableJoin) && (
- <MobileSignUpButton
- onClick={
- enableJoin
- ? handleJoinAlbum
- : handleSignUpOrInstall
- }
- >
- {buttonText}
- </MobileSignUpButton>
- )}
+ <MobileSignUpButton
+ onClick={
+ enableJoin
+ ? handleJoinAlbum
+ : () =>
+ window.open(
+ getEnteURL(isTouchscreen),
+ "_blank",
+ "noopener",
+ )
+ }
+ >
+ {enableJoin ? t("join_album") : t("get_ente")}
+ </MobileSignUpButton>
</ButtonGroup>
</MobileNavContainer>
diff --git a/web/apps/photos/src/components/TripLayout/TopNavButtons.tsx b/web/apps/photos/src/components/TripLayout/TopNavButtons.tsx
index a0ada41cfa..eb9b22e61d 100644
--- a/web/apps/photos/src/components/TripLayout/TopNavButtons.tsx
+++ b/web/apps/photos/src/components/TripLayout/TopNavButtons.tsx
@@ -11,7 +11,7 @@ import { Notification } from "ente-new/photos/components/Notification";
import { useJoinAlbum } from "hooks/useJoinAlbum";
import { t } from "i18next";
import { useState } from "react";
-import { getSignUpOrInstallURL } from "utils/public-album";
+import { getEnteURL } from "utils/public-album";
interface TopNavButtonsProps {
onAddPhotos?: () => void;
@@ -53,22 +53,6 @@ export const TopNavButtons: React.FC<TopNavButtonsProps> = ({
}
};
- const handleSignUpOrInstall = () => {
- if (typeof window !== "undefined") {
- window.open(
- getSignUpOrInstallURL(isTouchscreen),
- "_blank",
- "noopener",
- );
- }
- };
-
- const buttonText = enableJoin
- ? t("join_album")
- : isTouchscreen
- ? t("install")
- : t("sign_up");
-
return (
<>
<ButtonContainer>
@@ -96,15 +80,20 @@ export const TopNavButtons: React.FC<TopNavButtonsProps> = ({
</NavButton>
)}
- {(!onAddPhotos || enableJoin) && (
- <SignUpButton
- onClick={
- enableJoin ? handleJoinAlbum : handleSignUpOrInstall
- }
- >
- {buttonText}
- </SignUpButton>
- )}
+ <SignUpButton
+ onClick={
+ enableJoin
+ ? handleJoinAlbum
+ : () =>
+ window.open(
+ getEnteURL(isTouchscreen),
+ "_blank",
+ "noopener",
+ )
+ }
+ >
+ {enableJoin ? t("join_album") : t("get_ente")}
+ </SignUpButton>
</ButtonContainer>
<Notification
diff --git a/web/apps/photos/src/components/TripLayout/index.tsx b/web/apps/photos/src/components/TripLayout/index.tsx
index bd48fd3585..edc225aeac 100644
--- a/web/apps/photos/src/components/TripLayout/index.tsx
+++ b/web/apps/photos/src/components/TripLayout/index.tsx
@@ -614,7 +614,6 @@ export const TripLayout: React.FC<TripLayoutProps> = ({
{collection && credentials?.current && collectionKey && (
<PublicFeedSidebar
{...publicFeedVisibilityProps}
- albumName={collectionTitle}
files={files}
credentials={credentials.current}
collectionKey={collectionKey}
diff --git a/web/apps/photos/src/pages/shared-albums.tsx b/web/apps/photos/src/pages/shared-albums.tsx
index 5366005517..12b0107fee 100644
--- a/web/apps/photos/src/pages/shared-albums.tsx
+++ b/web/apps/photos/src/pages/shared-albums.tsx
@@ -6,14 +6,7 @@ import AddPhotoAlternateOutlinedIcon from "@mui/icons-material/AddPhotoAlternate
import CloseIcon from "@mui/icons-material/Close";
import DownloadIcon from "@mui/icons-material/Download";
-import {
- Box,
- Button,
- IconButton,
- Stack,
- styled,
- Tooltip,
-} from "@mui/material";
+import { Box, Button, IconButton, Stack, styled, Tooltip } from "@mui/material";
import Typography from "@mui/material/Typography";
import { FeedIcon } from "components/Collections/CollectionHeader";
import { DownloadStatusNotifications } from "components/DownloadStatusNotifications";
@@ -25,10 +18,7 @@ import {
AccountsPageContents,
AccountsPageTitle,
} from "ente-accounts/components/layouts/centered-paper";
-import {
- SpacedRow,
- Stack100vhCenter,
-} from "ente-base/components/containers";
+import { SpacedRow, Stack100vhCenter } from "ente-base/components/containers";
import { EnteLogo } from "ente-base/components/EnteLogo";
import {
LoadingIndicator,
@@ -41,7 +31,10 @@ import {
SingleInputForm,
type SingleInputFormProps,
} from "ente-base/components/SingleInputForm";
-import { useIsSmallWidth } from "ente-base/components/utils/hooks";
+import {
+ useIsSmallWidth,
+ useIsTouchscreen,
+} from "ente-base/components/utils/hooks";
import { useModalVisibility } from "ente-base/components/utils/modal";
import { useBaseContext } from "ente-base/context";
import {
@@ -102,6 +95,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { type FileWithPath } from "react-dropzone";
import { uploadManager } from "services/upload-manager";
import { getSelectedFiles, type SelectedState } from "utils/file";
+import { getEnteURL } from "utils/public-album";
export default function PublicCollectionGallery() {
const { showMiniDialog, onGenericError } = useBaseContext();
@@ -745,6 +739,7 @@ const PrimaryActionButton: React.FC<PrimaryActionButtonProps> = ({
collectionKey,
credentials,
}) => {
+ const isTouchscreen = useIsTouchscreen();
const { handleJoinAlbum } = useJoinAlbum({
publicCollection,
accessToken,
@@ -760,8 +755,12 @@ const PrimaryActionButton: React.FC<PrimaryActionButtonProps> = ({
);
}
+ const handleGetEnte = () => {
+ window.open(getEnteURL(isTouchscreen), "_blank", "noopener");
+ };
+
return (
- <GreenButton color="accent" href="https://ente.io">
+ <GreenButton color="accent" onClick={handleGetEnte}>
{t("get_ente")}
</GreenButton>
);
@@ -883,4 +882,6 @@ const fileListFooterHeight = 24;
* It scrolls along with the content. It has a fixed height,
* {@link fileListFooterHeight}.
*/
-const FileListFooter: React.FC = () => <Box sx={{ height: fileListFooterHeight }} />;
+const FileListFooter: React.FC = () => (
+ <Box sx={{ height: fileListFooterHeight }} />
+);
diff --git a/web/apps/photos/src/utils/public-album.ts b/web/apps/photos/src/utils/public-album.ts
index 7cd852766d..970b63635a 100644
--- a/web/apps/photos/src/utils/public-album.ts
+++ b/web/apps/photos/src/utils/public-album.ts
@@ -1,9 +1,9 @@
-import { photosAppOrigin } from "ente-base/origins";
-
/**
- * Get the appropriate URL for sign up or install based on platform.
+ * Get the appropriate URL for "Get Ente" button based on platform.
+ *
+ * Returns app store URLs for iOS/Android devices, ente.io for desktop.
*/
-export const getSignUpOrInstallURL = (isTouchscreen: boolean): string => {
+export const getEnteURL = (isTouchscreen: boolean): string => {
if (isTouchscreen) {
// For mobile devices, redirect to app stores
const userAgent = navigator.userAgent || "";
@@ -20,6 +20,6 @@ export const getSignUpOrInstallURL = (isTouchscreen: boolean): string => {
}
// For other touchscreen devices, fall back to web
}
- // For desktop or other platforms, redirect to photos app
- return photosAppOrigin();
+ // For desktop or other platforms, redirect to ente.io
+ return "https://ente.io";
};