silent sync before collection selector and uploadFile
This commit is contained in:
parent
e1a30b076c
commit
abd738df85
|
@ -37,6 +37,7 @@ interface Props {
|
||||||
directlyShowNextModal: boolean;
|
directlyShowNextModal: boolean;
|
||||||
collectionsAndTheirLatestFile: CollectionAndItsLatestFile[];
|
collectionsAndTheirLatestFile: CollectionAndItsLatestFile[];
|
||||||
attributes: CollectionSelectorAttributes;
|
attributes: CollectionSelectorAttributes;
|
||||||
|
syncWithRemote:(force?: boolean, silent?:boolean)=>Promise<void>;
|
||||||
}
|
}
|
||||||
function CollectionSelector({
|
function CollectionSelector({
|
||||||
attributes,
|
attributes,
|
||||||
|
@ -45,10 +46,14 @@ function CollectionSelector({
|
||||||
...props
|
...props
|
||||||
}: Props) {
|
}: Props) {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (directlyShowNextModal && attributes) {
|
const main=async ()=>{
|
||||||
props.onHide();
|
await props.syncWithRemote(true, true);
|
||||||
attributes.showNextModal();
|
if (directlyShowNextModal && attributes) {
|
||||||
}
|
props.onHide();
|
||||||
|
attributes.showNextModal();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
main();
|
||||||
}, [attributes]);
|
}, [attributes]);
|
||||||
|
|
||||||
if (!attributes) {
|
if (!attributes) {
|
||||||
|
|
|
@ -15,7 +15,7 @@ import { logError } from 'utils/sentry';
|
||||||
import { FileRejection } from 'react-dropzone';
|
import { FileRejection } from 'react-dropzone';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
syncWithRemote: (force?: boolean) => Promise<void>;
|
syncWithRemote: (force?: boolean, silent?: boolean) => Promise<void>;
|
||||||
setBannerMessage;
|
setBannerMessage;
|
||||||
acceptedFiles: globalThis.File[];
|
acceptedFiles: globalThis.File[];
|
||||||
existingFiles: File[];
|
existingFiles: File[];
|
||||||
|
@ -200,7 +200,7 @@ export default function Upload(props: Props) {
|
||||||
try {
|
try {
|
||||||
props.setUploadInProgress(true);
|
props.setUploadInProgress(true);
|
||||||
props.closeCollectionSelector();
|
props.closeCollectionSelector();
|
||||||
await props.syncWithRemote(true);
|
await props.syncWithRemote(true, true);
|
||||||
await UploadService.uploadFiles(
|
await UploadService.uploadFiles(
|
||||||
filesWithCollectionToUpload,
|
filesWithCollectionToUpload,
|
||||||
props.existingFiles,
|
props.existingFiles,
|
||||||
|
@ -227,7 +227,7 @@ export default function Upload(props: Props) {
|
||||||
try {
|
try {
|
||||||
props.setUploadInProgress(true);
|
props.setUploadInProgress(true);
|
||||||
setFileProgress(null);
|
setFileProgress(null);
|
||||||
await props.syncWithRemote(true);
|
await props.syncWithRemote(true, true);
|
||||||
const localFiles= await getLocalFiles();
|
const localFiles= await getLocalFiles();
|
||||||
await UploadService.retryFailedFiles(localFiles);
|
await UploadService.retryFailedFiles(localFiles);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
|
@ -191,7 +191,7 @@ export default function Gallery() {
|
||||||
);
|
);
|
||||||
useEffect(() => setCollectionNamerView(true), [collectionNamerAttributes]);
|
useEffect(() => setCollectionNamerView(true), [collectionNamerAttributes]);
|
||||||
|
|
||||||
const syncWithRemote = async (force = false) => {
|
const syncWithRemote = async (force = false, silent=false) => {
|
||||||
if (syncInProgress.current && !force) {
|
if (syncInProgress.current && !force) {
|
||||||
resync.current= true;
|
resync.current= true;
|
||||||
return;
|
return;
|
||||||
|
@ -202,7 +202,7 @@ export default function Gallery() {
|
||||||
if (!(await isTokenValid())) {
|
if (!(await isTokenValid())) {
|
||||||
throw new Error(errorCodes.ERR_SESSION_EXPIRED);
|
throw new Error(errorCodes.ERR_SESSION_EXPIRED);
|
||||||
}
|
}
|
||||||
loadingBar.current?.continuousStart();
|
!silent && loadingBar.current?.continuousStart();
|
||||||
await billingService.updatePlans();
|
await billingService.updatePlans();
|
||||||
await billingService.syncSubscription();
|
await billingService.syncSubscription();
|
||||||
const collections = await syncCollections();
|
const collections = await syncCollections();
|
||||||
|
@ -230,7 +230,7 @@ export default function Gallery() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
loadingBar.current?.complete();
|
!silent && loadingBar.current?.complete();
|
||||||
}
|
}
|
||||||
syncInProgress.current=false;
|
syncInProgress.current=false;
|
||||||
if (resync.current) {
|
if (resync.current) {
|
||||||
|
@ -406,6 +406,7 @@ export default function Gallery() {
|
||||||
collectionsAndTheirLatestFile?.length === 0
|
collectionsAndTheirLatestFile?.length === 0
|
||||||
}
|
}
|
||||||
attributes={collectionSelectorAttributes}
|
attributes={collectionSelectorAttributes}
|
||||||
|
syncWithRemote={syncWithRemote}
|
||||||
/>
|
/>
|
||||||
<Upload
|
<Upload
|
||||||
syncWithRemote={syncWithRemote}
|
syncWithRemote={syncWithRemote}
|
||||||
|
|
Loading…
Reference in a new issue