diff --git a/web/ASC.Web.Client/src/components/pages/Settings/categories/data-management/manual-backup.js b/web/ASC.Web.Client/src/components/pages/Settings/categories/data-management/manual-backup.js index 3f128232b2..c7f566c24b 100644 --- a/web/ASC.Web.Client/src/components/pages/Settings/categories/data-management/manual-backup.js +++ b/web/ASC.Web.Client/src/components/pages/Settings/categories/data-management/manual-backup.js @@ -82,6 +82,47 @@ class ManualBackup extends React.Component { saveToSessionStorage("selectedStorage", ""); //for third party storages module }; + checkDownloadingProgress = async () => { + try { + let response; + [this.commonThirdPartyList, response] = await Promise.all([ + SelectFolderDialog.getCommonThirdPartyList(), + getBackupProgress(), + ]); + + if (response && !response.error) { + response.link && + response.link.slice(0, 1) === "/" && + this.setState({ + link: response.link, + }); + + this.setState({ + downloadingProgress: response.progress, + }); + + if (response.progress !== 100) { + this._isMounted && + this.setState({ + isLoadingData: true, + }); + + this.timerId = setInterval(() => this.getProgress(), 1000); + } else { + this.clearSessionStorage(); + } + } else { + this.clearSessionStorage(); + } + } catch (error) { + console.error(error); + } + + this.setState({ + isLoading: false, + }); + }; + componentDidMount() { this._isMounted = true; @@ -90,41 +131,7 @@ class ManualBackup extends React.Component { isLoading: true, }, function () { - SelectFolderDialog.getCommonThirdPartyList() - .then( - (thirdPartyArray) => (this.commonThirdPartyList = thirdPartyArray) - ) - .then(() => getBackupProgress()) - .then((response) => { - if (response) { - if (!response.error) { - response.link && - response.link.slice(0, 1) === "/" && - this.setState({ - link: response.link, - }); - this.setState({ - downloadingProgress: response.progress, - }); - if (response.progress !== 100) { - this._isMounted && - this.setState({ - isLoadingData: true, - }); - this.timerId = setInterval(() => this.getProgress(), 1000); - } else { - this.clearSessionStorage(); - } - } else { - this.clearSessionStorage(); - } - } - }) - .finally(() => - this.setState({ - isLoading: false, - }) - ); + this.checkDownloadingProgress(); } ); }