[mobile] Fix bug 50878
This commit is contained in:
parent
c632c239bd
commit
5a6dfc5e8e
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
@ -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};
|
|
@ -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 (
|
||||
<Fragment>
|
||||
<NavLeft>
|
||||
{props.isShowBack && <Link className={`btn-doc-back${props.disabledControls && ' disabled'}`} icon='icon-back' onClick={props.onBack}></Link>}
|
||||
{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
|
||||
})}
|
||||
|
|
|
@ -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};
|
|
@ -4,13 +4,14 @@ import { Device } from '../../../../common/mobile/utils/device';
|
|||
import EditorUIController from '../lib/patch'
|
||||
|
||||
const ToolbarView = props => {
|
||||
const isDisconnected = props.isDisconnected;
|
||||
return (
|
||||
<Fragment>
|
||||
<NavLeft>
|
||||
{props.isShowBack && <Link className={`btn-doc-back${props.disabledControls && ' disabled'}`} icon='icon-back' onClick={props.onBack}></Link>}
|
||||
{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 && <NavTitle>{props.docTitle}</NavTitle>}
|
||||
<NavRight>
|
||||
{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 => {
|
|||
<Link className={props.disabledControls ? 'disabled' : ''} icon='icon-edit' href={false} onClick={props.onEditDocument}></Link>
|
||||
}
|
||||
{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')
|
||||
})}
|
||||
|
|
|
@ -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};
|
|
@ -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 => {
|
|||
<Link className={props.disabledControls ? 'disabled' : ''} icon='icon-edit' href={false} onClick={props.onEditDocument}></Link>
|
||||
}
|
||||
{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')
|
||||
})}
|
||||
|
|
Loading…
Reference in a new issue