diff --git a/apps/common/mobile/lib/controller/collaboration/Collaboration.jsx b/apps/common/mobile/lib/controller/collaboration/Collaboration.jsx index 8104543e3..6cb82db7c 100644 --- a/apps/common/mobile/lib/controller/collaboration/Collaboration.jsx +++ b/apps/common/mobile/lib/controller/collaboration/Collaboration.jsx @@ -17,6 +17,7 @@ class CollaborationController extends Component { api.asc_registerCallback('asc_OnTryUndoInFastCollaborative', this.onTryUndoInFastCollaborative.bind(this)); }); + Common.Notifications.on('api:disconnect', this.onCoAuthoringDisconnect.bind(this)); Common.Notifications.on('document:ready', this.onDocumentReady.bind(this)); } diff --git a/apps/documenteditor/mobile/src/controller/Toolbar.jsx b/apps/documenteditor/mobile/src/controller/Toolbar.jsx index a0028b81c..79286c70a 100644 --- a/apps/documenteditor/mobile/src/controller/Toolbar.jsx +++ b/apps/documenteditor/mobile/src/controller/Toolbar.jsx @@ -1,10 +1,10 @@ import React, { useEffect, useState } from 'react'; -import { inject } from 'mobx-react'; +import { inject, observer } from 'mobx-react'; import { f7 } from 'framework7-react'; import { useTranslation } from 'react-i18next'; import ToolbarView from "../view/Toolbar"; -const ToolbarController = inject('storeAppOptions', 'users', 'storeReview')(props => { +const ToolbarController = inject('storeAppOptions', 'users', 'storeReview')(observer(props => { const {t} = useTranslation(); const _t = t("Toolbar", { returnObjects: true }); @@ -23,8 +23,6 @@ const ToolbarController = inject('storeAppOptions', 'users', 'storeReview')(prop api.asc_registerCallback('asc_onCanUndo', onApiCanUndo); api.asc_registerCallback('asc_onCanRedo', onApiCanRedo); api.asc_registerCallback('asc_onFocusObject', onApiFocusObject); - api.asc_registerCallback('asc_onCoAuthoringDisconnect', onCoAuthoringDisconnect); - Common.Notifications.on('api:disconnect', onCoAuthoringDisconnect); Common.Notifications.on('toolbar:activatecontrols', activateControls); Common.Notifications.on('toolbar:deactivateeditcontrols', deactivateEditControls); Common.Notifications.on('goback', goBack); @@ -37,10 +35,15 @@ const ToolbarController = inject('storeAppOptions', 'users', 'storeReview')(prop onDocumentReady(); } + if (isDisconnected) { + f7.popover.close(); + f7.sheet.close(); + f7.popup.close(); + } + return () => { Common.Notifications.off('document:ready', onDocumentReady); Common.Notifications.off('setdoctitle', setDocTitle); - Common.Notifications.off('api:disconnect', onCoAuthoringDisconnect); Common.Notifications.off('toolbar:activatecontrols', activateControls); Common.Notifications.off('toolbar:deactivateeditcontrols', deactivateEditControls); Common.Notifications.off('goback', goBack); @@ -49,7 +52,6 @@ const ToolbarController = inject('storeAppOptions', 'users', 'storeReview')(prop api.asc_unregisterCallback('asc_onCanUndo', onApiCanUndo); api.asc_unregisterCallback('asc_onCanRedo', onApiCanRedo); api.asc_unregisterCallback('asc_onFocusObject', onApiFocusObject); - api.asc_unregisterCallback('asc_onCoAuthoringDisconnect', onCoAuthoringDisconnect); } }); @@ -163,15 +165,6 @@ const ToolbarController = inject('storeAppOptions', 'users', 'storeReview')(prop } }; - const onCoAuthoringDisconnect = (enableDownload) => { - deactivateEditControls(enableDownload); - setCanUndo(false); - setCanRedo(false); - f7.popover.close(); - f7.sheet.close(); - f7.popup.close(); - }; - const [disabledControls, setDisabledControls] = useState(true); const activateControls = () => { setDisabledControls(false); @@ -200,8 +193,9 @@ const ToolbarController = inject('storeAppOptions', 'users', 'storeReview')(prop readerMode={readerMode} showEditDocument={showEditDocument} onEditDocument={onEditDocument} + isDisconnected={isDisconnected} /> ) -}); +})); export {ToolbarController as Toolbar}; \ No newline at end of file diff --git a/apps/documenteditor/mobile/src/view/Toolbar.jsx b/apps/documenteditor/mobile/src/view/Toolbar.jsx index aa45f2793..6a801fdd1 100644 --- a/apps/documenteditor/mobile/src/view/Toolbar.jsx +++ b/apps/documenteditor/mobile/src/view/Toolbar.jsx @@ -4,14 +4,15 @@ import { Device } from '../../../../common/mobile/utils/device'; import EditorUIController from '../lib/patch' const ToolbarView = props => { - const disableEditBtn = props.isObjectLocked || props.stateDisplayMode || props.disabledEditControls; + const isDisconnected = props.isDisconnected; + const disableEditBtn = props.isObjectLocked || props.stateDisplayMode || props.disabledEditControls || isDisconnected; return ( {props.isShowBack && } {Device.ios && props.isEdit && EditorUIController.getUndoRedo && EditorUIController.getUndoRedo({ - disabledUndo: !props.isCanUndo, - disabledRedo: !props.isCanRedo, + disabledUndo: !props.isCanUndo || isDisconnected, + disabledRedo: !props.isCanRedo || isDisconnected, onUndoClick: props.onUndo, onRedoClick: props.onRedo })} diff --git a/apps/presentationeditor/mobile/src/controller/Toolbar.jsx b/apps/presentationeditor/mobile/src/controller/Toolbar.jsx index 42a240a7b..87225a53d 100644 --- a/apps/presentationeditor/mobile/src/controller/Toolbar.jsx +++ b/apps/presentationeditor/mobile/src/controller/Toolbar.jsx @@ -1,10 +1,10 @@ import React, { useEffect, useState } from 'react'; -import { inject } from 'mobx-react'; +import { inject, observer } from 'mobx-react'; import { f7 } from 'framework7-react'; import { useTranslation } from 'react-i18next'; import ToolbarView from "../view/Toolbar"; -const ToolbarController = inject('storeAppOptions', 'users')(props => { +const ToolbarController = inject('storeAppOptions', 'users')(observer(props => { const {t} = useTranslation(); const _t = t("Toolbar", { returnObjects: true }); @@ -20,9 +20,7 @@ const ToolbarController = inject('storeAppOptions', 'users')(props => { api.asc_registerCallback('asc_onCanUndo', onApiCanUndo); api.asc_registerCallback('asc_onCanRedo', onApiCanRedo); api.asc_registerCallback('asc_onFocusObject', onApiFocusObject); - api.asc_registerCallback('asc_onCoAuthoringDisconnect', onCoAuthoringDisconnect); api.asc_registerCallback('asc_onCountPages', onApiCountPages); - Common.Notifications.on('api:disconnect', onCoAuthoringDisconnect); Common.Notifications.on('toolbar:activatecontrols', activateControls); Common.Notifications.on('toolbar:deactivateeditcontrols', deactivateEditControls); Common.Notifications.on('goback', goBack); @@ -35,10 +33,15 @@ const ToolbarController = inject('storeAppOptions', 'users')(props => { onDocumentReady(); } + if (isDisconnected) { + f7.popover.close(); + f7.sheet.close(); + f7.popup.close(); + } + return () => { Common.Notifications.off('document:ready', onDocumentReady); Common.Notifications.off('setdoctitle', setDocTitle); - Common.Notifications.off('api:disconnect', onCoAuthoringDisconnect); Common.Notifications.off('toolbar:activatecontrols', activateControls); Common.Notifications.off('toolbar:deactivateeditcontrols', deactivateEditControls); Common.Notifications.off('goback', goBack); @@ -47,7 +50,6 @@ const ToolbarController = inject('storeAppOptions', 'users')(props => { api.asc_unregisterCallback('asc_onCanUndo', onApiCanUndo); api.asc_unregisterCallback('asc_onCanRedo', onApiCanRedo); api.asc_unregisterCallback('asc_onFocusObject', onApiFocusObject); - api.asc_unregisterCallback('asc_onCoAuthoringDisconnect', onCoAuthoringDisconnect); api.asc_unregisterCallback('asc_onCountPages', onApiCountPages); } }); @@ -178,15 +180,6 @@ const ToolbarController = inject('storeAppOptions', 'users')(props => { setDisabledControls(false); }; - const onCoAuthoringDisconnect = (enableDownload) => { - deactivateEditControls(enableDownload); - setCanUndo(false); - setCanRedo(false); - f7.popover.close(); - f7.sheet.close(); - f7.popup.close(); - }; - const onEditDocument = () => { Common.Gateway.requestEditRights(); }; @@ -210,8 +203,9 @@ const ToolbarController = inject('storeAppOptions', 'users')(props => { displayCollaboration={displayCollaboration} showEditDocument={showEditDocument} onEditDocument={onEditDocument} + isDisconnected={isDisconnected} /> ) -}); +})); export {ToolbarController as Toolbar}; \ No newline at end of file diff --git a/apps/presentationeditor/mobile/src/view/Toolbar.jsx b/apps/presentationeditor/mobile/src/view/Toolbar.jsx index 903d9a05d..42f93da4f 100644 --- a/apps/presentationeditor/mobile/src/view/Toolbar.jsx +++ b/apps/presentationeditor/mobile/src/view/Toolbar.jsx @@ -4,13 +4,14 @@ import { Device } from '../../../../common/mobile/utils/device'; import EditorUIController from '../lib/patch' const ToolbarView = props => { + const isDisconnected = props.isDisconnected; return ( {props.isShowBack && } {Device.ios && props.isEdit && EditorUIController.getUndoRedo && EditorUIController.getUndoRedo({ - disabledUndo: !props.isCanUndo, - disabledRedo: !props.isCanRedo, + disabledUndo: !props.isCanUndo || isDisconnected, + disabledRedo: !props.isCanRedo || isDisconnected, onUndoClick: props.onUndo, onRedoClick: props.onRedo })} @@ -18,8 +19,8 @@ const ToolbarView = props => { {!Device.phone && {props.docTitle}} {Device.android && props.isEdit && EditorUIController.getUndoRedo && EditorUIController.getUndoRedo({ - disabledUndo: !props.isCanUndo, - disabledRedo: !props.isCanRedo, + disabledUndo: !props.isCanUndo || isDisconnected, + disabledRedo: !props.isCanRedo || isDisconnected, onUndoClick: props.onUndo, onRedoClick: props.onRedo })} @@ -28,8 +29,8 @@ const ToolbarView = props => { } {props.isEdit && EditorUIController.getToolbarOptions && EditorUIController.getToolbarOptions({ - disabledAdd: props.disabledAdd || props.disabledControls, - disabledEdit: props.disabledEdit || props.disabledControls, + disabledAdd: props.disabledAdd || props.disabledControls || isDisconnected, + disabledEdit: props.disabledEdit || props.disabledControls || isDisconnected, onEditClick: () => props.openOptions('edit'), onAddClick: () => props.openOptions('add') })} diff --git a/apps/spreadsheeteditor/mobile/src/controller/Toolbar.jsx b/apps/spreadsheeteditor/mobile/src/controller/Toolbar.jsx index ade8d976a..8db15a70a 100644 --- a/apps/spreadsheeteditor/mobile/src/controller/Toolbar.jsx +++ b/apps/spreadsheeteditor/mobile/src/controller/Toolbar.jsx @@ -1,10 +1,10 @@ import React, { useEffect, useState } from 'react'; -import { inject } from 'mobx-react'; +import { inject, observer } from 'mobx-react'; import { f7 } from 'framework7-react'; import { useTranslation } from 'react-i18next'; import ToolbarView from "../view/Toolbar"; -const ToolbarController = inject('storeAppOptions', 'users', 'storeSpreadsheetInfo')(props => { +const ToolbarController = inject('storeAppOptions', 'users', 'storeSpreadsheetInfo')(observer(props => { const {t} = useTranslation(); const _t = t("Toolbar", { returnObjects: true }); @@ -24,9 +24,7 @@ const ToolbarController = inject('storeAppOptions', 'users', 'storeSpreadsheetIn api.asc_registerCallback('asc_onWorkbookLocked', onApiSelectionChanged); api.asc_registerCallback('asc_onWorksheetLocked', onApiSelectionChanged); api.asc_registerCallback('asc_onActiveSheetChanged', onApiActiveSheetChanged); - api.asc_registerCallback('asc_onCoAuthoringDisconnect', onCoAuthoringDisconnect); - Common.Notifications.on('api:disconnect', onCoAuthoringDisconnect); Common.Notifications.on('toolbar:activatecontrols', activateControls); Common.Notifications.on('toolbar:deactivateeditcontrols', deactivateEditControls); Common.Notifications.on('goback', goBack); @@ -39,9 +37,14 @@ const ToolbarController = inject('storeAppOptions', 'users', 'storeSpreadsheetIn onDocumentReady(); } + if (isDisconnected) { + f7.popover.close(); + f7.sheet.close(); + f7.popup.close(); + } + return () => { Common.Notifications.off('document:ready', onDocumentReady); - Common.Notifications.off('api:disconnect', onCoAuthoringDisconnect); Common.Notifications.off('toolbar:activatecontrols', activateControls); Common.Notifications.off('toolbar:deactivateeditcontrols', deactivateEditControls); Common.Notifications.off('goback', goBack); @@ -54,7 +57,6 @@ const ToolbarController = inject('storeAppOptions', 'users', 'storeSpreadsheetIn api.asc_unregisterCallback('asc_onWorkbookLocked', onApiSelectionChanged); api.asc_unregisterCallback('asc_onWorksheetLocked', onApiSelectionChanged); api.asc_unregisterCallback('asc_onActiveSheetChanged', onApiActiveSheetChanged); - api.asc_unregisterCallback('asc_onCoAuthoringDisconnect', onCoAuthoringDisconnect); } }); @@ -179,15 +181,6 @@ const ToolbarController = inject('storeAppOptions', 'users', 'storeSpreadsheetIn setDisabledControls(false); }; - const onCoAuthoringDisconnect = (enableDownload) => { - deactivateEditControls(enableDownload); - setCanUndo(false); - setCanRedo(false); - f7.popover.close(); - f7.sheet.close(); - f7.popup.close(); - }; - const onEditDocument = () => { Common.Gateway.requestEditRights(); }; @@ -208,8 +201,9 @@ const ToolbarController = inject('storeAppOptions', 'users', 'storeSpreadsheetIn displayCollaboration={displayCollaboration} showEditDocument={showEditDocument} onEditDocument={onEditDocument} + isDisconnected={isDisconnected} /> ) -}); +})); export {ToolbarController as Toolbar}; \ No newline at end of file diff --git a/apps/spreadsheeteditor/mobile/src/view/Toolbar.jsx b/apps/spreadsheeteditor/mobile/src/view/Toolbar.jsx index 93c1c7740..0cf7909be 100644 --- a/apps/spreadsheeteditor/mobile/src/view/Toolbar.jsx +++ b/apps/spreadsheeteditor/mobile/src/view/Toolbar.jsx @@ -4,9 +4,10 @@ import { Device } from '../../../../common/mobile/utils/device'; import EditorUIController from '../lib/patch' const ToolbarView = props => { + const isDisconnected = props.isDisconnected; const undo_box = props.isEdit && EditorUIController.toolbarOptions ? EditorUIController.toolbarOptions.getUndoRedo({ - disabledUndo: !props.isCanUndo, - disabledRedo: !props.isCanRedo, + disabledUndo: !props.isCanUndo || isDisconnected, + disabledRedo: !props.isCanRedo || isDisconnected, onUndoClick: props.onUndo, onRedoClick: props.onRedo }) : null; @@ -23,7 +24,7 @@ const ToolbarView = props => { } {props.isEdit && EditorUIController.toolbarOptions && EditorUIController.toolbarOptions.getEditOptions({ - disabled: props.disabledEditControls || props.disabledControls, + disabled: props.disabledEditControls || props.disabledControls || isDisconnected, onEditClick: () => props.openOptions('edit'), onAddClick: () => props.openOptions('add') })}