Merge branch 'public-album-styling' into bug-fix-public-sharing
This commit is contained in:
commit
eb714a145b
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "bada-frame",
|
||||
"version": "0.4.3",
|
||||
"version": "0.4.4",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
|
|
|
@ -238,7 +238,9 @@ export default function Sidebar(props: Props) {
|
|||
onHide={() => setRecoveryModalView(false)}
|
||||
somethingWentWrong={() =>
|
||||
props.setDialogMessage({
|
||||
title: constants.RECOVER_KEY_GENERATION_FAILED,
|
||||
title: constants.ERROR,
|
||||
content:
|
||||
constants.RECOVER_KEY_GENERATION_FAILED,
|
||||
close: { variant: 'danger' },
|
||||
})
|
||||
}
|
||||
|
|
|
@ -129,10 +129,7 @@ const InProgressSection = (props: InProgressProps) => {
|
|||
<FileList>
|
||||
{fileList.map(({ fileName, progress }) => (
|
||||
<li key={fileName}>
|
||||
{constants.FILE_UPLOAD_PROGRESS(
|
||||
fileName,
|
||||
progress
|
||||
)}
|
||||
{`${fileName} - ${progress}%`}
|
||||
</li>
|
||||
))}
|
||||
</FileList>
|
||||
|
@ -235,7 +232,7 @@ export default function UploadProgress(props: Props) {
|
|||
/>
|
||||
<ResultSection
|
||||
fileUploadResultMap={fileUploadResultMap}
|
||||
fileUploadResult={FileUploadResults.SKIPPED}
|
||||
fileUploadResult={FileUploadResults.ALREADY_UPLOADED}
|
||||
sectionTitle={constants.SKIPPED_FILES}
|
||||
sectionInfo={constants.SKIPPED_INFO}
|
||||
/>
|
||||
|
|
|
@ -37,7 +37,7 @@ function GoToEnte() {
|
|||
if (os === OS.ANDROID || os === OS.IOS) {
|
||||
return constants.INSTALL;
|
||||
} else {
|
||||
return constants.SIGNUP_OR_LOGIN;
|
||||
return constants.SIGN_UP;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -30,11 +30,11 @@ export enum UPLOAD_STAGES {
|
|||
}
|
||||
|
||||
export enum FileUploadResults {
|
||||
FAILED = -1,
|
||||
SKIPPED = -2,
|
||||
UNSUPPORTED = -3,
|
||||
BLOCKED = -4,
|
||||
TOO_LARGE = -5,
|
||||
LARGER_THAN_AVAILABLE_STORAGE = -6,
|
||||
UPLOADED = 100,
|
||||
FAILED,
|
||||
ALREADY_UPLOADED,
|
||||
UNSUPPORTED,
|
||||
BLOCKED,
|
||||
TOO_LARGE,
|
||||
LARGER_THAN_AVAILABLE_STORAGE,
|
||||
UPLOADED,
|
||||
}
|
||||
|
|
|
@ -24,8 +24,16 @@ class DownloadManager {
|
|||
}
|
||||
if (!this.thumbnailObjectURLPromise.get(file.id)) {
|
||||
const downloadPromise = async () => {
|
||||
const thumbnailCache = await caches.open('thumbs');
|
||||
const cacheResp: Response = await thumbnailCache.match(
|
||||
const thumbnailCache = await (async () => {
|
||||
try {
|
||||
return await caches.open('thumbs');
|
||||
} catch (e) {
|
||||
return null;
|
||||
// ignore
|
||||
}
|
||||
})();
|
||||
|
||||
const cacheResp: Response = await thumbnailCache?.match(
|
||||
file.id.toString()
|
||||
);
|
||||
if (cacheResp) {
|
||||
|
@ -34,7 +42,7 @@ class DownloadManager {
|
|||
const thumb = await this.downloadThumb(token, file);
|
||||
const thumbBlob = new Blob([thumb]);
|
||||
try {
|
||||
await thumbnailCache.put(
|
||||
await thumbnailCache?.put(
|
||||
file.id.toString(),
|
||||
new Response(thumbBlob)
|
||||
);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import {
|
||||
FileUploadResults,
|
||||
RANDOM_PERCENTAGE_PROGRESS_FOR_PUT,
|
||||
UPLOAD_STAGES,
|
||||
} from 'constants/upload';
|
||||
|
@ -9,7 +10,7 @@ class UIService {
|
|||
private filesUploaded: number;
|
||||
private totalFileCount: number;
|
||||
private fileProgress: Map<string, number>;
|
||||
private uploadResult: Map<string, number>;
|
||||
private uploadResult: Map<string, FileUploadResults>;
|
||||
private progressUpdater: ProgressUpdater;
|
||||
|
||||
init(progressUpdater: ProgressUpdater) {
|
||||
|
@ -47,8 +48,8 @@ class UIService {
|
|||
this.updateProgressBarUI();
|
||||
}
|
||||
|
||||
moveFileToResultList(filename: string) {
|
||||
this.uploadResult.set(filename, this.fileProgress.get(filename));
|
||||
moveFileToResultList(filename: string, uploadResult: FileUploadResults) {
|
||||
this.uploadResult.set(filename, uploadResult);
|
||||
this.fileProgress.delete(filename);
|
||||
this.updateProgressBarUI();
|
||||
}
|
||||
|
|
|
@ -185,7 +185,11 @@ class UploadManager {
|
|||
this.failedFiles.push(fileWithCollection);
|
||||
}
|
||||
|
||||
UIService.moveFileToResultList(fileWithCollection.file.name);
|
||||
UIService.moveFileToResultList(
|
||||
fileWithCollection.file.name,
|
||||
fileUploadResult
|
||||
);
|
||||
UploadService.reducePendingUploadCount();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,6 +36,10 @@ class UploadService {
|
|||
await this.preFetchUploadURLs();
|
||||
}
|
||||
|
||||
reducePendingUploadCount() {
|
||||
this.pendingUploadCount--;
|
||||
}
|
||||
|
||||
async readFile(
|
||||
worker: any,
|
||||
reader: FileReader,
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import { EnteFile } from 'types/file';
|
||||
import { sleep } from 'utils/common';
|
||||
import { handleUploadError, CustomError } from 'utils/error';
|
||||
import { decryptFile } from 'utils/file';
|
||||
import { logError } from 'utils/sentry';
|
||||
|
@ -22,7 +21,6 @@ import {
|
|||
import { FILE_TYPE } from 'constants/file';
|
||||
import { FileUploadResults } from 'constants/upload';
|
||||
|
||||
const TwoSecondInMillSeconds = 2000;
|
||||
const FIVE_GB_IN_BYTES = 5 * 1024 * 1024 * 1024;
|
||||
interface UploadResponse {
|
||||
fileUploadResult: FileUploadResults;
|
||||
|
@ -46,12 +44,6 @@ export default async function uploader(
|
|||
|
||||
try {
|
||||
if (rawFile.size >= FIVE_GB_IN_BYTES) {
|
||||
UIService.setFileProgress(
|
||||
rawFile.name,
|
||||
FileUploadResults.TOO_LARGE
|
||||
);
|
||||
// wait two second before removing the file from the progress in file section
|
||||
await sleep(TwoSecondInMillSeconds);
|
||||
return { fileUploadResult: FileUploadResults.TOO_LARGE };
|
||||
}
|
||||
fileTypeInfo = await getFileType(reader, rawFile);
|
||||
|
@ -65,10 +57,7 @@ export default async function uploader(
|
|||
);
|
||||
|
||||
if (fileAlreadyInCollection(existingFilesInCollection, metadata)) {
|
||||
UIService.setFileProgress(rawFile.name, FileUploadResults.SKIPPED);
|
||||
// wait two second before removing the file from the progress in file section
|
||||
await sleep(TwoSecondInMillSeconds);
|
||||
return { fileUploadResult: FileUploadResults.SKIPPED };
|
||||
return { fileUploadResult: FileUploadResults.ALREADY_UPLOADED };
|
||||
}
|
||||
|
||||
file = await UploadService.readFile(
|
||||
|
@ -105,7 +94,6 @@ export default async function uploader(
|
|||
const uploadedFile = await UploadHttpClient.uploadFile(uploadFile);
|
||||
const decryptedFile = await decryptFile(uploadedFile, collection.key);
|
||||
|
||||
UIService.setFileProgress(rawFile.name, FileUploadResults.UPLOADED);
|
||||
UIService.increaseFileUploaded();
|
||||
return {
|
||||
fileUploadResult: FileUploadResults.UPLOADED,
|
||||
|
@ -118,32 +106,15 @@ export default async function uploader(
|
|||
const error = handleUploadError(e);
|
||||
switch (error.message) {
|
||||
case CustomError.ETAG_MISSING:
|
||||
UIService.setFileProgress(
|
||||
rawFile.name,
|
||||
FileUploadResults.BLOCKED
|
||||
);
|
||||
return { fileUploadResult: FileUploadResults.BLOCKED };
|
||||
case CustomError.UNSUPPORTED_FILE_FORMAT:
|
||||
UIService.setFileProgress(
|
||||
rawFile.name,
|
||||
FileUploadResults.UNSUPPORTED
|
||||
);
|
||||
return { fileUploadResult: FileUploadResults.UNSUPPORTED };
|
||||
|
||||
case CustomError.FILE_TOO_LARGE:
|
||||
UIService.setFileProgress(
|
||||
rawFile.name,
|
||||
FileUploadResults.LARGER_THAN_AVAILABLE_STORAGE
|
||||
);
|
||||
return {
|
||||
fileUploadResult:
|
||||
FileUploadResults.LARGER_THAN_AVAILABLE_STORAGE,
|
||||
};
|
||||
default:
|
||||
UIService.setFileProgress(
|
||||
rawFile.name,
|
||||
FileUploadResults.FAILED
|
||||
);
|
||||
return { fileUploadResult: FileUploadResults.FAILED };
|
||||
}
|
||||
} finally {
|
||||
|
|
|
@ -72,13 +72,21 @@ export const setRecoveryKey = (token: string, recoveryKey: RecoveryKey) =>
|
|||
});
|
||||
|
||||
export const logoutUser = async () => {
|
||||
// ignore server logout result as logoutUser can be triggered before sign up or on token expiry
|
||||
await _logout();
|
||||
clearKeys();
|
||||
clearData();
|
||||
await caches.delete('thumbs');
|
||||
await clearFiles();
|
||||
router.push(PAGES.ROOT);
|
||||
try {
|
||||
// ignore server logout result as logoutUser can be triggered before sign up or on token expiry
|
||||
await _logout();
|
||||
clearKeys();
|
||||
clearData();
|
||||
try {
|
||||
await caches.delete('thumbs');
|
||||
} catch (e) {
|
||||
// ignore
|
||||
}
|
||||
await clearFiles();
|
||||
router.push(PAGES.ROOT);
|
||||
} catch (e) {
|
||||
logError(e, 'logoutUser failed');
|
||||
}
|
||||
};
|
||||
|
||||
export const clearFiles = async () => {
|
||||
|
|
|
@ -4,7 +4,6 @@ import localForage from 'localforage';
|
|||
|
||||
if (runningInBrowser()) {
|
||||
localForage.config({
|
||||
driver: localForage.INDEXEDDB,
|
||||
name: 'ente-files',
|
||||
version: 1.0,
|
||||
storeName: 'files',
|
||||
|
|
|
@ -109,26 +109,6 @@ const englishConstants = {
|
|||
},
|
||||
UPLOADING_FILES: 'file upload',
|
||||
FILE_NOT_UPLOADED_LIST: 'the following files were not uploaded',
|
||||
FILE_UPLOAD_PROGRESS: (name: string, progress: number) => (
|
||||
<div id={name}>
|
||||
{name}
|
||||
{' - '}
|
||||
<span style={{ color: '#eee' }}>
|
||||
{(() => {
|
||||
switch (progress) {
|
||||
case -1:
|
||||
return 'failed';
|
||||
case -2:
|
||||
return 'already uploaded, skipping...';
|
||||
case -3:
|
||||
return 'unsupported file format, skipping....';
|
||||
default:
|
||||
return `${progress}%`;
|
||||
}
|
||||
})()}
|
||||
</span>
|
||||
</div>
|
||||
),
|
||||
SUBSCRIPTION_EXPIRED: (action) => (
|
||||
<>
|
||||
your subscription has expired, please a{' '}
|
||||
|
@ -636,7 +616,6 @@ const englishConstants = {
|
|||
REPORT_SUBMIT_SUCCESS_TITLE: 'report sent',
|
||||
REPORT_SUBMIT_FAILED: 'failed to sent report, try again',
|
||||
INSTALL: 'install',
|
||||
SIGNUP_OR_LOGIN: 'signup / login',
|
||||
ALBUM_URL: 'album url',
|
||||
PUBLIC_SHARING: 'public sharing',
|
||||
NOT_FOUND: '404 - not found',
|
||||
|
|
Loading…
Reference in a new issue