From 4c16858a3b3a4f6da3add4b1ea1bbf584a4a4bc2 Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Fri, 14 May 2021 15:26:03 +0300 Subject: [PATCH] [DE mobile] Fix long actions for downloading --- .../mobile/src/controller/Main.jsx | 3 +- .../src/controller/settings/Download.jsx | 31 +++++++++++-------- .../mobile/src/store/appOptions.js | 9 +++++- 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/apps/documenteditor/mobile/src/controller/Main.jsx b/apps/documenteditor/mobile/src/controller/Main.jsx index 80a71b939..558a9a093 100644 --- a/apps/documenteditor/mobile/src/controller/Main.jsx +++ b/apps/documenteditor/mobile/src/controller/Main.jsx @@ -198,6 +198,7 @@ class MainController extends Component { f7.emit('resize'); this._isDocReady = true; + appOptions.changeDocReady(true); this.api.SetDrawingFreeze(false); @@ -602,7 +603,7 @@ class MainController extends Component { this.api.asc_registerCallback('asc_onAdvancedOptions', (type, advOptions, mode, formatOptions) => { const {t} = this.props; const _t = t("Settings", { returnObjects: true }); - onAdvancedOptions(type, advOptions, mode, formatOptions, _t, this.props.storeAppOptions.canRequestClose); + onAdvancedOptions(type, advOptions, mode, formatOptions, _t, this._isDocReady, this.props.storeAppOptions.canRequestClose); }); } diff --git a/apps/documenteditor/mobile/src/controller/settings/Download.jsx b/apps/documenteditor/mobile/src/controller/settings/Download.jsx index 187b65c7b..7f7db5e3f 100644 --- a/apps/documenteditor/mobile/src/controller/settings/Download.jsx +++ b/apps/documenteditor/mobile/src/controller/settings/Download.jsx @@ -2,7 +2,8 @@ import React, { Component } from "react"; import Download from "../../view/settings/Download"; import { Device } from '../../../../../common/mobile/utils/device'; import { f7 } from 'framework7-react'; -import { withTranslation, useTranslation } from 'react-i18next'; +import { withTranslation } from 'react-i18next'; +import { observer, inject } from "mobx-react"; class DownloadController extends Component { constructor(props) { @@ -28,9 +29,10 @@ class DownloadController extends Component { f7.dialog.confirm( (format === Asc.c_oAscFileType.TXT) ? _t.textDownloadTxt : _t.textDownloadRtf, _t.notcriticalErrorTitle, - function () { + () => { if (format == Asc.c_oAscFileType.TXT) { - onAdvancedOptions(Asc.c_oAscAdvancedOptionsID.TXT, api.asc_getAdvancedOptions(), 2, new Asc.asc_CDownloadOptions(format), _t); + const isDocReady = this.props.storeAppOptions.isDocReady; + onAdvancedOptions(Asc.c_oAscAdvancedOptionsID.TXT, api.asc_getAdvancedOptions(), 2, new Asc.asc_CDownloadOptions(format), _t, isDocReady); } else { api.asc_DownloadAs(new Asc.asc_CDownloadOptions(format)); @@ -52,9 +54,10 @@ class DownloadController extends Component { ); } } -const DownloadWithTranslation = withTranslation()(DownloadController); -const onAdvancedOptions = (type, advOptions, mode, formatOptions, _t, canRequestClose) => { +const DownloadWithTranslation = inject("storeAppOptions")(observer(withTranslation()(DownloadController))); + +const onAdvancedOptions = (type, advOptions, mode, formatOptions, _t, isDocReady, canRequestClose) => { if ($$('.dlg-adv-options.modal-in').length > 0) return; const api = Common.EditorApi.get(); @@ -66,7 +69,8 @@ const onAdvancedOptions = (type, advOptions, mode, formatOptions, _t, canRequest pages.push(page.asc_getCodePage()); pagesName.push(page.asc_getCodePageName()); } - //me.onLongActionEnd(Asc.c_oAscAsyncActionType.BlockInteraction, LoadingDocument); + Common.Notifications.trigger('preloader:close'); + Common.Notifications.trigger('preloader:endAction', Asc.c_oAscAsyncActionType['BlockInteraction'], -256); const buttons = []; if (mode === 2) { buttons.push({ @@ -84,9 +88,9 @@ const onAdvancedOptions = (type, advOptions, mode, formatOptions, _t, canRequest } else { api.asc_setAdvancedOptions(type, new Asc.asc_CTextOptions(encoding)); } - //if (!me._isDocReady) { - //me.onLongActionBegin(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument); - //} + if (!isDocReady) { + Common.Notifications.trigger('preloader:beginAction', Asc.c_oAscAsyncActionType['BlockInteraction'], -256); + } } }); const dialog = f7.dialog.create({ @@ -117,16 +121,17 @@ const onAdvancedOptions = (type, advOptions, mode, formatOptions, _t, canRequest }); }); } else if (type == Asc.c_oAscAdvancedOptionsID.DRM) { - //me.onLongActionEnd(Asc.c_oAscAsyncActionType.BlockInteraction, LoadingDocument); + Common.Notifications.trigger('preloader:close'); + Common.Notifications.trigger('preloader:endAction', Asc.c_oAscAsyncActionType['BlockInteraction'], -256); const buttons = [{ text: 'OK', bold: true, onClick: function () { const password = document.getElementById('modal-password').value; api.asc_setAdvancedOptions(type, new Asc.asc_CDRMAdvancedOptions(password)); - //if (!me._isDocReady) { - //Common.Notifications.trigger('preloader:beginAction', Asc.c_oAscAsyncActionType['BlockInteraction'], this.LoadingDocument); - //} + if (!isDocReady) { + Common.Notifications.trigger('preloader:beginAction', Asc.c_oAscAsyncActionType['BlockInteraction'], -256); + } } }]; if (canRequestClose) diff --git a/apps/documenteditor/mobile/src/store/appOptions.js b/apps/documenteditor/mobile/src/store/appOptions.js index f0e5ddcdf..1c4303aa7 100644 --- a/apps/documenteditor/mobile/src/store/appOptions.js +++ b/apps/documenteditor/mobile/src/store/appOptions.js @@ -18,7 +18,9 @@ export class storeAppOptions { readerMode: observable, changeReaderMode: action, - canBrandingExt: observable + canBrandingExt: observable, + + isDocReady: observable }); } @@ -39,6 +41,11 @@ export class storeAppOptions { canBrandingExt = false; + isDocReady = false; + changeDocReady (value) { + this.isDocReady = value; + } + config = {}; setConfigOptions (config) { this.config = config;