patch missed stuff
This commit is contained in:
parent
5c7522b3b4
commit
c4d66b3ca4
|
@ -18,7 +18,7 @@ import {
|
|||
} from 'constants/gallery';
|
||||
import { PublicCollectionGalleryContext } from 'utils/publicCollectionGallery';
|
||||
import { ENTE_WEBSITE_LINK } from '@ente/shared/constants/urls';
|
||||
import { convertBytesToHumanReadable } from 'utils/file/size';
|
||||
import { convertBytesToHumanReadable } from '@ente/shared/utils/size';
|
||||
import { DeduplicateContext } from 'pages/deduplicate';
|
||||
import { FlexWrapper } from '@ente/shared/components/Container';
|
||||
import { Typography } from '@mui/material';
|
||||
|
|
|
@ -43,7 +43,7 @@ import { AppContext } from 'pages/_app';
|
|||
import { getEditorCloseConfirmationMessage } from 'utils/ui';
|
||||
import { logError } from '@ente/shared/sentry';
|
||||
import { getFileType } from 'services/typeDetectionService';
|
||||
import { downloadUsingAnchor } from 'utils/file';
|
||||
import { downloadUsingAnchor } from '@ente/shared/utils';
|
||||
|
||||
interface IProps {
|
||||
file: EnteFile;
|
||||
|
|
|
@ -1,83 +0,0 @@
|
|||
import React, { useContext, useEffect, useState } from 'react';
|
||||
import { downloadAsFile } from 'utils/file';
|
||||
import { getRecoveryKey } from '@ente/shared/crypto/helpers';
|
||||
import CodeBlock from '@ente/shared/components/CodeBlock';
|
||||
import {
|
||||
Button,
|
||||
Dialog,
|
||||
DialogActions,
|
||||
DialogContent,
|
||||
Typography,
|
||||
} from '@mui/material';
|
||||
import * as bip39 from 'bip39';
|
||||
import { DashedBorderWrapper } from './styledComponents';
|
||||
import { AppContext } from 'pages/_app';
|
||||
import DialogTitleWithCloseButton from '@ente/shared/components/DialogBox/TitleWithCloseButton';
|
||||
import { t } from 'i18next';
|
||||
|
||||
// mobile client library only supports english.
|
||||
bip39.setDefaultWordlist('english');
|
||||
|
||||
const RECOVERY_KEY_FILE_NAME = 'ente-recovery-key.txt';
|
||||
|
||||
interface Props {
|
||||
show: boolean;
|
||||
onHide: () => void;
|
||||
somethingWentWrong: any;
|
||||
}
|
||||
|
||||
function RecoveryKey({ somethingWentWrong, ...props }: Props) {
|
||||
const appContext = useContext(AppContext);
|
||||
const [recoveryKey, setRecoveryKey] = useState(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (!props.show) {
|
||||
return;
|
||||
}
|
||||
const main = async () => {
|
||||
try {
|
||||
const recoveryKey = await getRecoveryKey();
|
||||
setRecoveryKey(bip39.entropyToMnemonic(recoveryKey));
|
||||
} catch (e) {
|
||||
somethingWentWrong();
|
||||
props.onHide();
|
||||
}
|
||||
};
|
||||
main();
|
||||
}, [props.show]);
|
||||
|
||||
function onSaveClick() {
|
||||
downloadAsFile(RECOVERY_KEY_FILE_NAME, recoveryKey);
|
||||
props.onHide();
|
||||
}
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
fullScreen={appContext.isMobile}
|
||||
open={props.show}
|
||||
onClose={props.onHide}
|
||||
maxWidth="xs">
|
||||
<DialogTitleWithCloseButton onClose={props.onHide}>
|
||||
{t('RECOVERY_KEY')}
|
||||
</DialogTitleWithCloseButton>
|
||||
<DialogContent>
|
||||
<Typography mb={3}>{t('RECOVERY_KEY_DESCRIPTION')}</Typography>
|
||||
<DashedBorderWrapper>
|
||||
<CodeBlock code={recoveryKey} />
|
||||
<Typography m={2}>
|
||||
{t('KEY_NOT_STORED_DISCLAIMER')}
|
||||
</Typography>
|
||||
</DashedBorderWrapper>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button color="secondary" size="large" onClick={props.onHide}>
|
||||
{t('SAVE_LATER')}
|
||||
</Button>
|
||||
<Button color="accent" size="large" onClick={onSaveClick}>
|
||||
{t('SAVE')}
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
export default RecoveryKey;
|
|
@ -1,6 +1,5 @@
|
|||
import { AppContext } from 'pages/_app';
|
||||
import React, { useContext, useEffect, useState } from 'react';
|
||||
import { downloadAsFile } from 'utils/file';
|
||||
import { Trans } from 'react-i18next';
|
||||
import { t } from 'i18next';
|
||||
|
||||
|
@ -16,6 +15,7 @@ import {
|
|||
testZipWithRootFileReadingTest,
|
||||
} from '../../../tests/zip-file-reading.test';
|
||||
import { EnteMenuItem } from 'components/Menu/EnteMenuItem';
|
||||
import { downloadAsFile } from '@ente/shared/utils';
|
||||
|
||||
export default function DebugSection() {
|
||||
const appContext = useContext(AppContext);
|
||||
|
|
|
@ -2,7 +2,7 @@ import { useContext, useState } from 'react';
|
|||
import { t } from 'i18next';
|
||||
|
||||
// import FixLargeThumbnails from 'components/FixLargeThumbnail';
|
||||
import RecoveryKey from 'components/RecoveryKey';
|
||||
import RecoveryKey from '@ente/shared/components/RecoveryKey';
|
||||
import TwoFactorModal from 'components/TwoFactor/Modal';
|
||||
import { PHOTOS_PAGES as PAGES } from '@ente/shared/constants/pages';
|
||||
import { useRouter } from 'next/router';
|
||||
|
@ -20,6 +20,7 @@ import { THEME_COLOR } from '@ente/shared/themes/constants';
|
|||
|
||||
export default function UtilitySection({ closeSidebar }) {
|
||||
const router = useRouter();
|
||||
const appContext = useContext(AppContext);
|
||||
const {
|
||||
setDialogMessage,
|
||||
startLoading,
|
||||
|
@ -27,7 +28,7 @@ export default function UtilitySection({ closeSidebar }) {
|
|||
setWatchFolderView,
|
||||
themeColor,
|
||||
setThemeColor,
|
||||
} = useContext(AppContext);
|
||||
} = appContext;
|
||||
|
||||
const [recoverModalView, setRecoveryModalView] = useState(false);
|
||||
const [twoFactorModalView, setTwoFactorModalView] = useState(false);
|
||||
|
@ -144,6 +145,7 @@ export default function UtilitySection({ closeSidebar }) {
|
|||
label={t('PREFERENCES')}
|
||||
/>
|
||||
<RecoveryKey
|
||||
appContext={appContext}
|
||||
show={recoverModalView}
|
||||
onHide={closeRecoveryKeyModal}
|
||||
somethingWentWrong={somethingWentWrong}
|
||||
|
|
|
@ -3,7 +3,7 @@ import { addLogLine } from '@ente/shared/logging';
|
|||
import { logError } from '@ente/shared/sentry';
|
||||
import { ElectronFile } from 'types/upload';
|
||||
import { CustomError } from '@ente/shared/error';
|
||||
import { convertBytesToHumanReadable } from 'utils/file/size';
|
||||
import { convertBytesToHumanReadable } from '@ente/shared/utils/size';
|
||||
|
||||
class ElectronImageProcessorService {
|
||||
async convertToJPEG(fileBlob: Blob, filename: string): Promise<Blob> {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { ElectronFile } from 'types/upload';
|
||||
import { convertBytesToHumanReadable } from 'utils/file/size';
|
||||
import { convertBytesToHumanReadable } from '@ente/shared/utils/size';
|
||||
import { logError } from '@ente/shared/sentry';
|
||||
|
||||
export async function getUint8ArrayView(
|
||||
|
|
|
@ -10,7 +10,7 @@ import { logError } from '@ente/shared/sentry';
|
|||
import { getUint8ArrayView } from './readerService';
|
||||
import FileType, { FileTypeResult } from 'file-type';
|
||||
import { getFileSize } from './upload/fileService';
|
||||
import { convertBytesToHumanReadable } from 'utils/file/size';
|
||||
import { convertBytesToHumanReadable } from '@ente/shared/utils/size';
|
||||
|
||||
const TYPE_VIDEO = 'video';
|
||||
const TYPE_IMAGE = 'image';
|
||||
|
|
|
@ -4,7 +4,7 @@ import { logError } from '@ente/shared/sentry';
|
|||
import { BLACK_THUMBNAIL_BASE64 } from 'constants/upload';
|
||||
import * as FFmpegService from 'services/ffmpeg/ffmpegService';
|
||||
import ElectronAPIs from '@ente/shared/electron';
|
||||
import { convertBytesToHumanReadable } from 'utils/file/size';
|
||||
import { convertBytesToHumanReadable } from '@ente/shared/utils/size';
|
||||
import { ElectronFile, FileTypeInfo } from 'types/upload';
|
||||
import { getUint8ArrayView } from '../readerService';
|
||||
import { addLogLine } from '@ente/shared/logging';
|
||||
|
|
|
@ -14,7 +14,7 @@ import {
|
|||
Logger,
|
||||
} from 'types/upload';
|
||||
import { addLocalLog, addLogLine } from '@ente/shared/logging';
|
||||
import { convertBytesToHumanReadable } from 'utils/file/size';
|
||||
import { convertBytesToHumanReadable } from '@ente/shared/utils/size';
|
||||
import { sleep } from 'utils/common';
|
||||
import { addToCollection } from 'services/collectionService';
|
||||
import uploadCancelService from './uploadCancelService';
|
||||
|
|
|
@ -5,7 +5,7 @@ import { logError } from '@ente/shared/sentry';
|
|||
import { addLogLine } from '@ente/shared/logging';
|
||||
import { DedicatedConvertWorker } from 'worker/convert.worker';
|
||||
import { ComlinkWorker } from '@ente/shared/worker/comlinkWorker';
|
||||
import { convertBytesToHumanReadable } from 'utils/file/size';
|
||||
import { convertBytesToHumanReadable } from '@ente/shared/utils/size';
|
||||
import { getDedicatedConvertWorker } from 'utils/comlink/ComlinkConvertWorker';
|
||||
|
||||
const WORKER_POOL_SIZE = 2;
|
||||
|
|
|
@ -32,7 +32,7 @@ import { isArchivedFile, updateMagicMetadata } from 'utils/magicMetadata';
|
|||
|
||||
import { addLocalLog, addLogLine } from '@ente/shared/logging';
|
||||
import { CustomError } from '@ente/shared/error';
|
||||
import { convertBytesToHumanReadable } from './size';
|
||||
import { convertBytesToHumanReadable } from '@ente/shared/utils/size';
|
||||
import ComlinkCryptoWorker from '@ente/shared/crypto';
|
||||
import {
|
||||
deleteFromTrash,
|
||||
|
@ -49,6 +49,7 @@ import ElectronFSService from '@ente/shared/electron';
|
|||
import { getFileExportPath, getUniqueFileExportName } from 'utils/export';
|
||||
import imageProcessor from 'services/imageProcessor';
|
||||
import ElectronAPIs from '@ente/shared/electron';
|
||||
import { downloadUsingAnchor } from '@ente/shared/utils';
|
||||
|
||||
const WAIT_TIME_IMAGE_CONVERSION = 30 * 1000;
|
||||
|
||||
|
@ -62,14 +63,6 @@ export enum FILE_OPS_TYPE {
|
|||
DELETE_PERMANENTLY,
|
||||
}
|
||||
|
||||
export function downloadAsFile(filename: string, content: string) {
|
||||
const file = new Blob([content], {
|
||||
type: 'text/plain',
|
||||
});
|
||||
const fileURL = URL.createObjectURL(file);
|
||||
downloadUsingAnchor(fileURL, filename);
|
||||
}
|
||||
|
||||
export async function getUpdatedEXIFFileForDownload(
|
||||
fileReader: FileReader,
|
||||
file: EnteFile,
|
||||
|
@ -166,17 +159,6 @@ export async function downloadFile(
|
|||
}
|
||||
}
|
||||
|
||||
export function downloadUsingAnchor(link: string, name: string) {
|
||||
const a = document.createElement('a');
|
||||
a.style.display = 'none';
|
||||
a.href = link;
|
||||
a.download = name;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
URL.revokeObjectURL(link);
|
||||
a.remove();
|
||||
}
|
||||
|
||||
export function groupFilesBasedOnCollectionID(files: EnteFile[]) {
|
||||
const collectionWiseFiles = new Map<number, EnteFile[]>();
|
||||
for (const file of files) {
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
export function convertBytesToHumanReadable(
|
||||
bytes: number,
|
||||
precision = 2
|
||||
): string {
|
||||
if (bytes === 0 || isNaN(bytes)) {
|
||||
return '0 MB';
|
||||
}
|
||||
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(1024));
|
||||
const sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
||||
return (bytes / Math.pow(1024, i)).toFixed(precision) + ' ' + sizes[i];
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
import { Box, styled } from '@mui/material';
|
||||
|
||||
export const DashedBorderWrapper = styled(Box)(({ theme }) => ({
|
||||
border: `1px dashed ${theme.palette.grey.A400}`,
|
||||
borderRadius: theme.spacing(1),
|
||||
}));
|
|
@ -17,7 +17,7 @@ import {
|
|||
justSignedUp,
|
||||
setJustSignedUp,
|
||||
} from '@ente/shared/storage/localStorage/helpers';
|
||||
import RecoveryKey from '@ente/accounts/components/RecoveryKey';
|
||||
import RecoveryKey from '@ente/shared/components/RecoveryKey';
|
||||
import { PAGES } from '@ente/accounts/constants/pages';
|
||||
import { VerticallyCentered } from '@ente/shared/components/Container';
|
||||
import EnteSpinner from '@ente/shared/components/EnteSpinner';
|
||||
|
|
0
packages/shared/env/index.ts
vendored
0
packages/shared/env/index.ts
vendored
|
@ -0,0 +1,11 @@
|
|||
import * as Comlink from 'comlink';
|
||||
|
||||
// didn't work kept for reference, so that can try to make it work later in future hopefully
|
||||
export function setupResponseObjectTransferHandler() {
|
||||
const transferHandler: Comlink.TransferHandler<Response, ArrayBuffer> = {
|
||||
canHandle: (obj): obj is Response => obj instanceof Response,
|
||||
serialize: (response: Response) => [response.arrayBuffer() as any, []],
|
||||
deserialize: (arrayBuffer: ArrayBuffer) => new Response(arrayBuffer),
|
||||
};
|
||||
return Comlink.transferHandlers.set('RESPONSE', transferHandler);
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
import { Remote, wrap } from 'comlink';
|
||||
// import { WorkerElectronCacheStorageClient } from 'services/workerElectronCache/client';
|
||||
import { expose, Remote, wrap } from 'comlink';
|
||||
import { WorkerElectronCacheStorageClient } from '@ente/shared/storage/cacheStorage/workerElectron/client';
|
||||
import { addLocalLog } from '@ente/shared/logging';
|
||||
|
||||
export class ComlinkWorker<T extends new () => InstanceType<T>> {
|
||||
|
@ -17,7 +17,7 @@ export class ComlinkWorker<T extends new () => InstanceType<T>> {
|
|||
addLocalLog(() => `Initiated ${this.name}`);
|
||||
const comlink = wrap<T>(this.worker);
|
||||
this.remote = new comlink() as Promise<Remote<InstanceType<T>>>;
|
||||
// expose(WorkerElectronCacheStorageClient, this.worker);
|
||||
expose(WorkerElectronCacheStorageClient, this.worker);
|
||||
}
|
||||
|
||||
public getName() {
|
||||
|
|
Loading…
Reference in a new issue