From db7c7343c555cbfddcc334ef4cbe2fa124c4d012 Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Sat, 20 Mar 2021 19:01:26 +0300 Subject: [PATCH] [mobile] Add reset of coauthoring disconnect option in users store --- .../lib/controller/collaboration/Collaboration.jsx | 6 +++++- apps/common/mobile/lib/store/users.js | 9 ++++++++- .../documenteditor/mobile/src/controller/ContextMenu.jsx | 7 ++++--- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/apps/common/mobile/lib/controller/collaboration/Collaboration.jsx b/apps/common/mobile/lib/controller/collaboration/Collaboration.jsx index 07032e812..a1dbec1b2 100644 --- a/apps/common/mobile/lib/controller/collaboration/Collaboration.jsx +++ b/apps/common/mobile/lib/controller/collaboration/Collaboration.jsx @@ -8,10 +8,10 @@ class CollaborationController extends Component { Common.Notifications.on('configOptionsFill', () => { const api = Common.EditorApi.get(); - // this.api = api; api.asc_registerCallback('asc_onAuthParticipantsChanged', this.onChangeEditUsers.bind(this)); api.asc_registerCallback('asc_onParticipantsChanged', this.onChangeEditUsers.bind(this)); api.asc_registerCallback('asc_onConnectionStateChanged', this.onUserConnection.bind(this)); + api.asc_registerCallback('asc_onCoAuthoringDisconnect', this.onCoAuthoringDisconnect.bind(this)); }); Common.Notifications.on('document:ready', this.onDocumentReady.bind(this)); @@ -71,6 +71,10 @@ class CollaborationController extends Component { this.props.users.connection(change); } + onCoAuthoringDisconnect() { + this.props.users.resetDisconnected(true); + } + render() { return null } diff --git a/apps/common/mobile/lib/store/users.js b/apps/common/mobile/lib/store/users.js index e21eaf77f..57a7f5a06 100644 --- a/apps/common/mobile/lib/store/users.js +++ b/apps/common/mobile/lib/store/users.js @@ -8,12 +8,15 @@ export class storeUsers { reset: action, currentUser: observable, setCurrentUser: action, - connection: action + connection: action, + isDisconnected: observable, + resetDisconnected: action }) } users = []; currentUser; + isDisconnected = false; reset (users) { this.users = Object.values(users) @@ -41,6 +44,10 @@ export class storeUsers { !changed && change && (this.users[change.asc_getId()] = change); } + resetDisconnected (isDisconnected) { + this.isDisconnected = isDisconnected; + } + getInitials (name) { const fio = Common.Utils.UserInfoParser.getParsedName(name).split(' '); let initials = fio[0].substring(0, 1).toUpperCase(); diff --git a/apps/documenteditor/mobile/src/controller/ContextMenu.jsx b/apps/documenteditor/mobile/src/controller/ContextMenu.jsx index bdfa0b8d2..14facac9e 100644 --- a/apps/documenteditor/mobile/src/controller/ContextMenu.jsx +++ b/apps/documenteditor/mobile/src/controller/ContextMenu.jsx @@ -12,7 +12,8 @@ import { Device } from '../../../../common/mobile/utils/device'; isEdit: stores.storeAppOptions.isEdit, canViewComments: stores.storeAppOptions.canViewComments, canReview: stores.storeAppOptions.canReview, - users: stores.users + users: stores.users, + isDisconnected: stores.users.isDisconnected })) class ContextMenu extends ContextMenuController { constructor(props) { @@ -231,7 +232,7 @@ class ContextMenu extends ContextMenuController { const { t } = this.props; const _t = t("ContextMenu", { returnObjects: true }); - const { isEdit, canViewComments, canReview } = this.props; + const { isEdit, canViewComments, canReview, isDisconnected } = this.props; const api = Common.EditorApi.get(); const stack = api.getSelectedElements(); @@ -301,7 +302,7 @@ class ContextMenu extends ContextMenuController { items[indexAfter] = items.splice(indexBefore, 1, items[indexAfter])[0]; }; - if ( isEdit && !this.isDisconnected ) { + if ( isEdit && !isDisconnected ) { if ( !lockedText && !lockedTable && !lockedImage && !lockedHeader && canCopy ) { itemsIcon.push({ event: 'cut',