update to hadle new URL format

This commit is contained in:
Abhinav 2022-01-19 16:24:43 +05:30
parent 13ebc48f9c
commit 072e471f27
6 changed files with 30 additions and 29 deletions

View file

@ -24,7 +24,7 @@ import PublicCollectionDownloadManager from 'services/publicCollectionDownloadMa
import {
defaultPublicCollectionGalleryContext,
PublicCollectionGalleryContext,
} from 'pages/shared-album';
} from 'utils/publicCollectionGallery';
const Container = styled.div`
display: block;

View file

@ -9,7 +9,7 @@ import { GAP_BTW_TILES } from 'constants/gallery';
import {
defaultPublicCollectionGalleryContext,
PublicCollectionGalleryContext,
} from 'pages/shared-album';
} from 'utils/publicCollectionGallery';
import PublicCollectionDownloadManager from 'services/publicCollectionDownloadManager';
interface IProps {

View file

@ -2,7 +2,7 @@ import MessageDialog from 'components/MessageDialog';
import SubmitButton from 'components/SubmitButton';
import { REPORT_REASON } from 'constants/publicCollection';
import { Formik, FormikHelpers } from 'formik';
import { PublicCollectionGalleryContext } from 'pages/shared-album';
import { PublicCollectionGalleryContext } from 'utils/publicCollectionGallery';
import React, { useContext, useState } from 'react';
import { Form, FormControl } from 'react-bootstrap';
import { reportAbuse } from 'services/publicCollectionService';

View file

@ -1,13 +1,6 @@
import { ALL_SECTION } from 'constants/collection';
import PhotoFrame from 'components/PhotoFrame';
import React, {
createContext,
useContext,
useEffect,
useRef,
useState,
} from 'react';
import { PublicCollectionGalleryContextType } from 'types/publicCollection';
import React, { useContext, useEffect, useRef, useState } from 'react';
import {
getLocalPublicCollection,
getLocalPublicFiles,
@ -23,18 +16,11 @@ import ReportAbuse from 'components/pages/sharedAlbum/ReportAbuse';
import { AbuseReportForm } from 'components/pages/sharedAlbum/AbuseReportForm';
import MessageDialog, { MessageAttributes } from 'components/MessageDialog';
import GoToEnte from 'components/pages/sharedAlbum/GoToEnte';
export const defaultPublicCollectionGalleryContext: PublicCollectionGalleryContextType =
{
token: null,
accessedThroughSharedURL: false,
setDialogMessage: () => null,
};
export const PublicCollectionGalleryContext =
createContext<PublicCollectionGalleryContextType>(
defaultPublicCollectionGalleryContext
);
import {
defaultPublicCollectionGalleryContext,
PublicCollectionGalleryContext,
} from 'utils/publicCollectionGallery';
import { useRouter } from 'next/router';
export default function PublicCollectionGallery() {
const token = useRef<string>(null);
@ -52,15 +38,16 @@ export default function PublicCollectionGallery() {
const openMessageDialog = () => setMessageDialogView(true);
const closeMessageDialog = () => setMessageDialogView(false);
const router = useRouter();
useEffect(() => {
const main = async () => {
url.current = window.location.href;
const urlParams = new URLSearchParams(window.location.search);
const eToken = urlParams.get('accessToken');
const eToken = (router.query.token?.[0] ?? '') as string;
const eCollectionKey = decodeURIComponent(
urlParams.get('collectionKey')
window.location.hash.slice(1)
);
if (!eToken || !eCollectionKey) {
return;
}
token.current = eToken;
collectionKey.current = eCollectionKey;
const localCollection = await getLocalPublicCollection(

View file

@ -110,7 +110,7 @@ export async function downloadCollection(
export function transformShareURLForHost(url: string, collectionKey: string) {
const host = window.location.host;
return `${url}&collectionKey=${encodeURIComponent(collectionKey)}`.replace(
return `${url}#${encodeURIComponent(collectionKey)}`.replace(
'https://albums.ente.io',
`http://${host}/shared-album`
);

View file

@ -0,0 +1,14 @@
import { createContext } from 'react';
import { PublicCollectionGalleryContextType } from 'types/publicCollection';
export const defaultPublicCollectionGalleryContext: PublicCollectionGalleryContextType =
{
token: null,
accessedThroughSharedURL: false,
setDialogMessage: () => null,
};
export const PublicCollectionGalleryContext =
createContext<PublicCollectionGalleryContextType>(
defaultPublicCollectionGalleryContext
);