Skip to content

armgit / ente

Public Imported from GitHub
0

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

join album improvements

Anand Baburajan9af28ac57916
diff --git a/web/apps/photos/src/hooks/useJoinAlbum.ts b/web/apps/photos/src/hooks/useJoinAlbum.ts
index 3b42291629..36d9291816 100644
--- a/web/apps/photos/src/hooks/useJoinAlbum.ts
+++ b/web/apps/photos/src/hooks/useJoinAlbum.ts
@@ -28,8 +28,8 @@ const buildWebRedirectURL = (
jwtToken?: string,
): string => {
const webAppURL = photosAppOrigin();
- const jwtParam = jwtToken ? `&jwt=${encodeURIComponent(jwtToken)}` : "";
- return `${webAppURL}/?joinAlbum=${accessToken}&collectionId=${collectionId}${jwtParam}#${currentHash}`;
+ const hashSuffix = jwtToken ? `&jwt=${encodeURIComponent(jwtToken)}` : "";
+ return `${webAppURL}/?joinAlbum=${accessToken}&collectionId=${collectionId}#${currentHash}${hashSuffix}`;
};
/**
diff --git a/web/apps/photos/src/pages/index.tsx b/web/apps/photos/src/pages/index.tsx
index d990a5d273..873883b842 100644
--- a/web/apps/photos/src/pages/index.tsx
+++ b/web/apps/photos/src/pages/index.tsx
@@ -64,12 +64,15 @@ const Page: React.FC = () => {
const joinAlbumParam = currentURL.searchParams.get("joinAlbum");
if (joinAlbumParam && joinAlbumParam !== "true") {
try {
- // Format: ?joinAlbum=accessToken&collectionId=123&jwt=<jwtToken>#collectionKeyHash
+ // Format: ?joinAlbum=accessToken&collectionId=123#collectionKeyHash&jwt=<jwtToken>
const accessToken = joinAlbumParam;
const collectionIdParam =
currentURL.searchParams.get("collectionId");
- const collectionKeyHash = currentURL.hash.slice(1);
- const jwtFromURL = currentURL.searchParams.get("jwt");
+ const [collectionKeyHash, fragmentParams = ""] =
+ currentURL.hash.slice(1).split("&", 2);
+ const jwtFromURL =
+ new URLSearchParams(fragmentParams).get("jwt") ??
+ undefined;
if (accessToken && collectionKeyHash && collectionIdParam) {
// Import the necessary functions to convert the collection key
@@ -115,11 +118,7 @@ const Page: React.FC = () => {
currentURL.host == albumsURL.host) &&
currentURL.pathname != "/shared-albums"
) {
- const end = currentURL.hash.lastIndexOf("&");
- const hash = currentURL.hash.slice(
- 1,
- end !== -1 ? end : undefined,
- );
+ const [hash] = currentURL.hash.slice(1).split("&", 1);
await router.replace({
pathname: "/shared-albums",
search: currentURL.search,