[mobile] Add reset of coauthoring disconnect option in users store

This commit is contained in:
JuliaSvinareva 2021-03-20 19:01:26 +03:00
parent eda4736916
commit db7c7343c5
3 changed files with 17 additions and 5 deletions

View file

@ -8,10 +8,10 @@ class CollaborationController extends Component {
Common.Notifications.on('configOptionsFill', () => { Common.Notifications.on('configOptionsFill', () => {
const api = Common.EditorApi.get(); const api = Common.EditorApi.get();
// this.api = api;
api.asc_registerCallback('asc_onAuthParticipantsChanged', this.onChangeEditUsers.bind(this)); api.asc_registerCallback('asc_onAuthParticipantsChanged', this.onChangeEditUsers.bind(this));
api.asc_registerCallback('asc_onParticipantsChanged', 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_onConnectionStateChanged', this.onUserConnection.bind(this));
api.asc_registerCallback('asc_onCoAuthoringDisconnect', this.onCoAuthoringDisconnect.bind(this));
}); });
Common.Notifications.on('document:ready', this.onDocumentReady.bind(this)); Common.Notifications.on('document:ready', this.onDocumentReady.bind(this));
@ -71,6 +71,10 @@ class CollaborationController extends Component {
this.props.users.connection(change); this.props.users.connection(change);
} }
onCoAuthoringDisconnect() {
this.props.users.resetDisconnected(true);
}
render() { render() {
return null return null
} }

View file

@ -8,12 +8,15 @@ export class storeUsers {
reset: action, reset: action,
currentUser: observable, currentUser: observable,
setCurrentUser: action, setCurrentUser: action,
connection: action connection: action,
isDisconnected: observable,
resetDisconnected: action
}) })
} }
users = []; users = [];
currentUser; currentUser;
isDisconnected = false;
reset (users) { reset (users) {
this.users = Object.values(users) this.users = Object.values(users)
@ -41,6 +44,10 @@ export class storeUsers {
!changed && change && (this.users[change.asc_getId()] = change); !changed && change && (this.users[change.asc_getId()] = change);
} }
resetDisconnected (isDisconnected) {
this.isDisconnected = isDisconnected;
}
getInitials (name) { getInitials (name) {
const fio = Common.Utils.UserInfoParser.getParsedName(name).split(' '); const fio = Common.Utils.UserInfoParser.getParsedName(name).split(' ');
let initials = fio[0].substring(0, 1).toUpperCase(); let initials = fio[0].substring(0, 1).toUpperCase();

View file

@ -12,7 +12,8 @@ import { Device } from '../../../../common/mobile/utils/device';
isEdit: stores.storeAppOptions.isEdit, isEdit: stores.storeAppOptions.isEdit,
canViewComments: stores.storeAppOptions.canViewComments, canViewComments: stores.storeAppOptions.canViewComments,
canReview: stores.storeAppOptions.canReview, canReview: stores.storeAppOptions.canReview,
users: stores.users users: stores.users,
isDisconnected: stores.users.isDisconnected
})) }))
class ContextMenu extends ContextMenuController { class ContextMenu extends ContextMenuController {
constructor(props) { constructor(props) {
@ -231,7 +232,7 @@ class ContextMenu extends ContextMenuController {
const { t } = this.props; const { t } = this.props;
const _t = t("ContextMenu", { returnObjects: true }); 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 api = Common.EditorApi.get();
const stack = api.getSelectedElements(); const stack = api.getSelectedElements();
@ -301,7 +302,7 @@ class ContextMenu extends ContextMenuController {
items[indexAfter] = items.splice(indexBefore, 1, items[indexAfter])[0]; items[indexAfter] = items.splice(indexBefore, 1, items[indexAfter])[0];
}; };
if ( isEdit && !this.isDisconnected ) { if ( isEdit && !isDisconnected ) {
if ( !lockedText && !lockedTable && !lockedImage && !lockedHeader && canCopy ) { if ( !lockedText && !lockedTable && !lockedImage && !lockedHeader && canCopy ) {
itemsIcon.push({ itemsIcon.push({
event: 'cut', event: 'cut',