From 8974612ff4f58cbdabb6c7bb9bc3da6cb4c35155 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 9 Mar 2021 17:06:44 +0300 Subject: [PATCH] Change api events: send onDocumentStateChange only after onDocumentReady, don't send false on loading. --- apps/documenteditor/main/app/controller/Main.js | 6 +++--- apps/documenteditor/mobile/app/controller/Main.js | 7 ++++--- apps/presentationeditor/main/app/controller/Main.js | 6 +++--- apps/presentationeditor/mobile/app/controller/Main.js | 7 ++++--- apps/spreadsheeteditor/main/app/controller/Main.js | 10 ++++++---- apps/spreadsheeteditor/mobile/app/controller/Main.js | 7 ++++--- 6 files changed, 24 insertions(+), 19 deletions(-) diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index f4e20e493..7fd8440d1 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -156,7 +156,7 @@ define([ weakCompare : function(obj1, obj2){return obj1.type === obj2.type;} }); - this._state = {isDisconnected: false, usersCount: 1, fastCoauth: true, lostEditingRights: false, licenseType: false}; + this._state = {isDisconnected: false, usersCount: 1, fastCoauth: true, lostEditingRights: false, licenseType: false, isDocModified: false}; this.languages = null; // Initialize viewport @@ -1798,7 +1798,7 @@ define([ if (window.document.title != title) window.document.title = title; - Common.Gateway.setDocumentModified(isModified); + this._isDocReady && (this._state.isDocModified !== isModified) && Common.Gateway.setDocumentModified(isModified); if (isModified && (!this._state.fastCoauth || this._state.usersCount<2)) this.getApplication().getController('Statusbar').setStatusCaption('', true); @@ -1809,7 +1809,7 @@ define([ onDocumentModifiedChanged: function() { var isModified = this.api.asc_isDocumentCanSave(); if (this._state.isDocModified !== isModified) { - Common.Gateway.setDocumentModified(this.api.isDocumentModified()); + this._isDocReady && Common.Gateway.setDocumentModified(this.api.isDocumentModified()); } this.updateWindowTitle(); diff --git a/apps/documenteditor/mobile/app/controller/Main.js b/apps/documenteditor/mobile/app/controller/Main.js index 30e047d66..66f8d59fc 100644 --- a/apps/documenteditor/mobile/app/controller/Main.js +++ b/apps/documenteditor/mobile/app/controller/Main.js @@ -80,7 +80,8 @@ define([ usersCount : 1, fastCoauth : true, lostEditingRights : false, - licenseType : false + licenseType : false, + isDocModified: false }; // Initialize viewport @@ -1144,7 +1145,7 @@ define([ if (window.document.title != title) window.document.title = title; - Common.Gateway.setDocumentModified(isModified); + this._isDocReady && (this._state.isDocModified !== isModified) && Common.Gateway.setDocumentModified(isModified); this._state.isDocModified = isModified; } }, @@ -1152,7 +1153,7 @@ define([ onDocumentModifiedChanged: function() { var isModified = this.api.asc_isDocumentCanSave(); if (this._state.isDocModified !== isModified) { - Common.Gateway.setDocumentModified(this.api.isDocumentModified()); + this._isDocReady && Common.Gateway.setDocumentModified(this.api.isDocumentModified()); } this.updateWindowTitle(); diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index ef200e2b0..2a40265c2 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -134,7 +134,7 @@ define([ onLaunch: function() { var me = this; - this._state = {isDisconnected: false, usersCount: 1, fastCoauth: true, lostEditingRights: false, licenseType: false}; + this._state = {isDisconnected: false, usersCount: 1, fastCoauth: true, lostEditingRights: false, licenseType: false, isDocModified: false}; this.languages = null; window.storagename = 'presentation'; @@ -1469,7 +1469,7 @@ define([ if ( window.document.title != title ) window.document.title = title; - Common.Gateway.setDocumentModified(isModified); + this._isDocReady && (this._state.isDocModified !== isModified) && Common.Gateway.setDocumentModified(isModified); if (isModified && (!this._state.fastCoauth || this._state.usersCount<2)) this.getApplication().getController('Statusbar').setStatusCaption('', true); @@ -1483,7 +1483,7 @@ define([ onDocumentModifiedChanged: function() { var isModified = this.api.asc_isDocumentCanSave(); if (this._state.isDocModified !== isModified) { - Common.Gateway.setDocumentModified(this.api.isDocumentModified()); + this._isDocReady && Common.Gateway.setDocumentModified(this.api.isDocumentModified()); } this.updateWindowTitle(); diff --git a/apps/presentationeditor/mobile/app/controller/Main.js b/apps/presentationeditor/mobile/app/controller/Main.js index 2ea83421d..4c9c14894 100644 --- a/apps/presentationeditor/mobile/app/controller/Main.js +++ b/apps/presentationeditor/mobile/app/controller/Main.js @@ -80,7 +80,8 @@ define([ usersCount : 1, fastCoauth : true, lostEditingRights : false, - licenseType : false + licenseType : false, + isDocModified: false }; // Initialize viewport @@ -1063,7 +1064,7 @@ define([ if (window.document.title != title) window.document.title = title; - Common.Gateway.setDocumentModified(isModified); + this._isDocReady && (this._state.isDocModified !== isModified) && Common.Gateway.setDocumentModified(isModified); this._state.isDocModified = isModified; } }, @@ -1071,7 +1072,7 @@ define([ onDocumentModifiedChanged: function() { var isModified = this.api.asc_isDocumentCanSave(); if (this._state.isDocModified !== isModified) { - Common.Gateway.setDocumentModified(this.api.isDocumentModified()); + this._isDocReady && Common.Gateway.setDocumentModified(this.api.isDocumentModified()); } this.updateWindowTitle(); diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 0cf548dae..a3920b07e 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -161,7 +161,7 @@ define([ // $(document.body).css('position', 'absolute'); var me = this; - this._state = {isDisconnected: false, usersCount: 1, fastCoauth: true, lostEditingRights: false, licenseType: false}; + this._state = {isDisconnected: false, usersCount: 1, fastCoauth: true, lostEditingRights: false, licenseType: false, isDocModified: false}; if (!Common.Utils.isBrowserSupported()){ Common.Utils.showBrowserRestriction(); @@ -1739,7 +1739,7 @@ define([ window.document.title = title; } - Common.Gateway.setDocumentModified(change); + this._isDocReady && (this._state.isDocModified !== change) && Common.Gateway.setDocumentModified(change); this._state.isDocModified = change; } @@ -1750,8 +1750,10 @@ define([ onDocumentModifiedChanged: function(change) { this.updateWindowTitle(change); - Common.Gateway.setDocumentModified(change); - + if (this._state.isDocModified !== change) { + this._isDocReady && Common.Gateway.setDocumentModified(change); + } + if (this.toolbarView && this.toolbarView.btnCollabChanges && this.api) { var isSyncButton = this.toolbarView.btnCollabChanges.cmpEl.hasClass('notify'), forcesave = this.appOptions.forcesave, diff --git a/apps/spreadsheeteditor/mobile/app/controller/Main.js b/apps/spreadsheeteditor/mobile/app/controller/Main.js index 2092e1f43..1c6d2d289 100644 --- a/apps/spreadsheeteditor/mobile/app/controller/Main.js +++ b/apps/spreadsheeteditor/mobile/app/controller/Main.js @@ -81,7 +81,8 @@ define([ usersCount : 1, fastCoauth : true, lostEditingRights : false, - licenseType : false + licenseType : false, + isDocModified: false }; // Initialize viewport @@ -1209,7 +1210,7 @@ define([ if (window.document.title != title) window.document.title = title; - Common.Gateway.setDocumentModified(isModified); + this._isDocReady && (this._state.isDocModified !== isModified) && Common.Gateway.setDocumentModified(isModified); this._state.isDocModified = isModified; } }, @@ -1217,7 +1218,7 @@ define([ onDocumentModifiedChanged: function() { var isModified = this.api.asc_isDocumentCanSave(); if (this._state.isDocModified !== isModified) { - Common.Gateway.setDocumentModified(this.api.asc_isDocumentModified()); + this._isDocReady && Common.Gateway.setDocumentModified(this.api.asc_isDocumentModified()); } this.updateWindowTitle();