silent sync before collection selector and uploadFile

This commit is contained in:
Abhinav-grd 2021-07-27 07:28:23 +05:30
parent e1a30b076c
commit abd738df85
3 changed files with 16 additions and 10 deletions

View file

@ -37,6 +37,7 @@ interface Props {
directlyShowNextModal: boolean;
collectionsAndTheirLatestFile: CollectionAndItsLatestFile[];
attributes: CollectionSelectorAttributes;
syncWithRemote:(force?: boolean, silent?:boolean)=>Promise<void>;
}
function CollectionSelector({
attributes,
@ -45,10 +46,14 @@ function CollectionSelector({
...props
}: Props) {
useEffect(() => {
const main=async ()=>{
await props.syncWithRemote(true, true);
if (directlyShowNextModal && attributes) {
props.onHide();
attributes.showNextModal();
}
};
main();
}, [attributes]);
if (!attributes) {

View file

@ -15,7 +15,7 @@ import { logError } from 'utils/sentry';
import { FileRejection } from 'react-dropzone';
interface Props {
syncWithRemote: (force?: boolean) => Promise<void>;
syncWithRemote: (force?: boolean, silent?: boolean) => Promise<void>;
setBannerMessage;
acceptedFiles: globalThis.File[];
existingFiles: File[];
@ -200,7 +200,7 @@ export default function Upload(props: Props) {
try {
props.setUploadInProgress(true);
props.closeCollectionSelector();
await props.syncWithRemote(true);
await props.syncWithRemote(true, true);
await UploadService.uploadFiles(
filesWithCollectionToUpload,
props.existingFiles,
@ -227,7 +227,7 @@ export default function Upload(props: Props) {
try {
props.setUploadInProgress(true);
setFileProgress(null);
await props.syncWithRemote(true);
await props.syncWithRemote(true, true);
const localFiles= await getLocalFiles();
await UploadService.retryFailedFiles(localFiles);
} catch (err) {

View file

@ -191,7 +191,7 @@ export default function Gallery() {
);
useEffect(() => setCollectionNamerView(true), [collectionNamerAttributes]);
const syncWithRemote = async (force = false) => {
const syncWithRemote = async (force = false, silent=false) => {
if (syncInProgress.current && !force) {
resync.current= true;
return;
@ -202,7 +202,7 @@ export default function Gallery() {
if (!(await isTokenValid())) {
throw new Error(errorCodes.ERR_SESSION_EXPIRED);
}
loadingBar.current?.continuousStart();
!silent && loadingBar.current?.continuousStart();
await billingService.updatePlans();
await billingService.syncSubscription();
const collections = await syncCollections();
@ -230,7 +230,7 @@ export default function Gallery() {
break;
}
} finally {
loadingBar.current?.complete();
!silent && loadingBar.current?.complete();
}
syncInProgress.current=false;
if (resync.current) {
@ -406,6 +406,7 @@ export default function Gallery() {
collectionsAndTheirLatestFile?.length === 0
}
attributes={collectionSelectorAttributes}
syncWithRemote={syncWithRemote}
/>
<Upload
syncWithRemote={syncWithRemote}