Merge branch 'main' into demo

This commit is contained in:
Abhinav 2022-08-06 15:44:25 +05:30
commit 60a6cf6fc1
3 changed files with 32 additions and 48 deletions

View file

@ -32,12 +32,15 @@ import { useRouter } from 'next/router';
import SingleInputForm, { import SingleInputForm, {
SingleInputFormProps, SingleInputFormProps,
} from 'components/SingleInputForm'; } from 'components/SingleInputForm';
import { Card } from 'react-bootstrap';
import { logError } from 'utils/sentry'; import { logError } from 'utils/sentry';
import SharedAlbumNavbar from 'components/pages/sharedAlbum/Navbar'; import SharedAlbumNavbar from 'components/pages/sharedAlbum/Navbar';
import { CollectionInfo } from 'components/Collections/CollectionInfo'; import { CollectionInfo } from 'components/Collections/CollectionInfo';
import { CollectionInfoBarWrapper } from 'components/Collections/styledComponents'; import { CollectionInfoBarWrapper } from 'components/Collections/styledComponents';
import { ITEM_TYPE, TimeStampListItem } from 'components/PhotoList'; import { ITEM_TYPE, TimeStampListItem } from 'components/PhotoList';
import FormContainer from 'components/Form/FormContainer';
import FormPaper from 'components/Form/FormPaper';
import FormPaperTitle from 'components/Form/FormPaper/Title';
import Typography from '@mui/material/Typography';
const Loader = () => ( const Loader = () => (
<VerticallyCentered> <VerticallyCentered>
@ -267,21 +270,23 @@ export default function PublicCollectionGallery() {
} }
if (isPasswordProtected && !passwordJWTToken.current) { if (isPasswordProtected && !passwordJWTToken.current) {
return ( return (
<VerticallyCentered> <FormContainer>
<Card style={{ maxWidth: '332px' }} className="text-center"> <FormPaper>
<Card.Body style={{ padding: '40px 30px' }}> <FormPaperTitle>{constants.PASSWORD}</FormPaperTitle>
<Card.Subtitle style={{ marginBottom: '2rem' }}> <Typography
{constants.LINK_PASSWORD} color={'text.secondary'}
</Card.Subtitle> mb={2}
<SingleInputForm variant="body2">
callback={verifyLinkPassword} {constants.LINK_PASSWORD}
placeholder={constants.RETURN_PASSPHRASE_HINT} </Typography>
buttonText={'unlock'} <SingleInputForm
fieldType="password" callback={verifyLinkPassword}
/> placeholder={constants.RETURN_PASSPHRASE_HINT}
</Card.Body> buttonText={'unlock'}
</Card> fieldType="password"
</VerticallyCentered> />
</FormPaper>
</FormContainer>
); );
} }
if (!publicFiles) { if (!publicFiles) {

View file

@ -4,7 +4,6 @@ import CryptoWorker from 'utils/crypto';
import { import {
generateStreamFromArrayBuffer, generateStreamFromArrayBuffer,
convertForPreview, convertForPreview,
needsConversionForPreview,
createTypedObjectURL, createTypedObjectURL,
} from 'utils/file'; } from 'utils/file';
import HTTPService from './HTTPService'; import HTTPService from './HTTPService';
@ -90,20 +89,13 @@ class DownloadManager {
return decrypted; return decrypted;
}; };
getFile = async ( getFile = async (file: EnteFile, forPreview = false) => {
file: EnteFile, const fileKey = forPreview ? `${file.id}_preview` : `${file.id}`;
forPreview = false,
tokenOverride?: string
) => {
const shouldBeConverted = forPreview && needsConversionForPreview(file);
const fileKey = shouldBeConverted
? `${file.id}_converted`
: `${file.id}`;
try { try {
const getFilePromise = async (convert: boolean) => { const getFilePromise = async () => {
const fileStream = await this.downloadFile(file, tokenOverride); const fileStream = await this.downloadFile(file);
const fileBlob = await new Response(fileStream).blob(); const fileBlob = await new Response(fileStream).blob();
if (convert) { if (forPreview) {
const convertedBlobs = await convertForPreview( const convertedBlobs = await convertForPreview(
file, file,
fileBlob fileBlob
@ -123,10 +115,7 @@ class DownloadManager {
]; ];
}; };
if (!this.fileObjectURLPromise.get(fileKey)) { if (!this.fileObjectURLPromise.get(fileKey)) {
this.fileObjectURLPromise.set( this.fileObjectURLPromise.set(fileKey, getFilePromise());
fileKey,
getFilePromise(shouldBeConverted)
);
} }
const fileURLs = await this.fileObjectURLPromise.get(fileKey); const fileURLs = await this.fileObjectURLPromise.get(fileKey);
return fileURLs; return fileURLs;

View file

@ -3,11 +3,7 @@ import {
getPublicCollectionThumbnailURL, getPublicCollectionThumbnailURL,
} from 'utils/common/apiUtil'; } from 'utils/common/apiUtil';
import CryptoWorker from 'utils/crypto'; import CryptoWorker from 'utils/crypto';
import { import { generateStreamFromArrayBuffer, convertForPreview } from 'utils/file';
generateStreamFromArrayBuffer,
convertForPreview,
needsConversionForPreview,
} from 'utils/file';
import HTTPService from './HTTPService'; import HTTPService from './HTTPService';
import { EnteFile } from 'types/file'; import { EnteFile } from 'types/file';
@ -107,19 +103,16 @@ class PublicCollectionDownloadManager {
passwordToken: string, passwordToken: string,
forPreview = false forPreview = false
) => { ) => {
const shouldBeConverted = forPreview && needsConversionForPreview(file); const fileKey = forPreview ? `${file.id}_preview` : `${file.id}`;
const fileKey = shouldBeConverted
? `${file.id}_converted`
: `${file.id}`;
try { try {
const getFilePromise = async (convert: boolean) => { const getFilePromise = async () => {
const fileStream = await this.downloadFile( const fileStream = await this.downloadFile(
token, token,
passwordToken, passwordToken,
file file
); );
const fileBlob = await new Response(fileStream).blob(); const fileBlob = await new Response(fileStream).blob();
if (convert) { if (forPreview) {
const convertedBlobs = await convertForPreview( const convertedBlobs = await convertForPreview(
file, file,
fileBlob fileBlob
@ -131,10 +124,7 @@ class PublicCollectionDownloadManager {
return [URL.createObjectURL(fileBlob)]; return [URL.createObjectURL(fileBlob)];
}; };
if (!this.fileObjectURLPromise.get(fileKey)) { if (!this.fileObjectURLPromise.get(fileKey)) {
this.fileObjectURLPromise.set( this.fileObjectURLPromise.set(fileKey, getFilePromise());
fileKey,
getFilePromise(shouldBeConverted)
);
} }
const fileURLs = await this.fileObjectURLPromise.get(fileKey); const fileURLs = await this.fileObjectURLPromise.get(fileKey);
return fileURLs; return fileURLs;