Skip to content

armgit / ente

Public Imported from GitHub
0

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

Fix Trip redirect to match existing redirect pattern

anandbaburajandaf364092d87
diff --git a/web/apps/photos/src/pages/shared-albums.tsx b/web/apps/photos/src/pages/shared-albums.tsx
index 3a17c55b2f..5b00da386f 100644
--- a/web/apps/photos/src/pages/shared-albums.tsx
+++ b/web/apps/photos/src/pages/shared-albums.tsx
@@ -172,6 +172,7 @@ export default function PublicCollectionGallery() {
*/
const main = async () => {
let redirectingToWebsite = false;
+ let redirectingToAlbumsApp = false;
try {
const currentURL = new URL(window.location.href);
const t = currentURL.searchParams.get("t");
@@ -188,6 +189,24 @@ export default function PublicCollectionGallery() {
const accessToken = t;
let accessTokenJWT: string | undefined;
if (collection) {
+ // On custom domains, redirect Trip albums to albums.ente.io/...
+ // because custom domains do not support the Trip layout fully
+ if (
+ collection.pubMagicMetadata?.data.layout === "trip" &&
+ shouldOnlyServeAlbumsApp
+ ) {
+ const currentURL = new URL(window.location.href);
+ const albumsURL = new URL(albumsAppOrigin());
+
+ if (currentURL.host !== albumsURL.host) {
+ albumsURL.search = currentURL.search;
+ albumsURL.hash = currentURL.hash;
+
+ window.location.href = albumsURL.href;
+ redirectingToAlbumsApp = true;
+ }
+ }
+
setReferralCode(
(await savedLastPublicCollectionReferralCode()) ?? "",
);
@@ -210,7 +229,7 @@ export default function PublicCollectionGallery() {
void updateShouldDisableCFUploadProxy();
await publicAlbumsRemotePull();
} finally {
- if (!redirectingToWebsite) {
+ if (!redirectingToWebsite && !redirectingToAlbumsApp) {
setLoading(false);
}
}
@@ -236,24 +255,6 @@ export default function PublicCollectionGallery() {
await pullCollection(accessToken, collectionKey.current!);
setReferralCode(userReferralCode);
- // On custom domains, redirect Trip albums to albums.ente.io/...
- // because custom domains do not support the Trip layout fully
- if (
- collection.pubMagicMetadata?.data.layout === "trip" &&
- shouldOnlyServeAlbumsApp
- ) {
- const currentURL = new URL(window.location.href);
- const albumsURL = new URL(albumsAppOrigin());
-
- if (currentURL.host !== albumsURL.host) {
- albumsURL.search = currentURL.search;
- albumsURL.hash = currentURL.hash;
-
- window.location.href = albumsURL.href;
- return;
- }
- }
-
setPublicCollection(collection);
const isPasswordProtected =
!!collection.publicURLs[0]?.passwordEnabled;