diff --git a/apps/api/documents/api.js b/apps/api/documents/api.js index f496d4f8a8..68694d4c3d 100644 --- a/apps/api/documents/api.js +++ b/apps/api/documents/api.js @@ -283,7 +283,7 @@ 'onError': , 'onWarning': , 'onInfo': ,// send view or edit mode - 'onOutdatedVersion': ,// send when previous version is opened + 'onOutdatedVersion': ,// send when previous version is opened, deprecated: use onRequestRefreshFile/refreshFile instead 'onDownloadAs': ,// send url of downloaded file as a response for downloadAs method 'onRequestSaveAs': , 'onCollaborativeChanges': ,// send when other user co-edit document @@ -305,6 +305,7 @@ 'onSaveDocument': 'save document from binary', 'onRequestStartFilling': // used in pdf-form edit mode. must call startFilling method 'onSubmit': // send when filled form is submitted successfully + 'onRequestRefreshFile': // send when file version is updated. use instead of onOutdatedVersion } } @@ -375,6 +376,7 @@ _config.editorConfig.canRequestReferenceSource = _config.events && !!_config.events.onRequestReferenceSource; _config.editorConfig.canSaveDocumentToBinary = _config.events && !!_config.events.onSaveDocument; _config.editorConfig.canStartFilling = _config.events && !!_config.events.onRequestStartFilling; + _config.editorConfig.canRequestRefreshFile = _config.events && !!_config.events.onRequestRefreshFile; _config.frameEditorId = placeholderId; _config.parentOrigin = window.location.origin; diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index edc46d0b84..2b1f4b1aaf 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -250,9 +250,6 @@ define([ Common.NotificationCenter.on('editing:disable', _.bind(this.onEditingDisable, this)); Common.NotificationCenter.on('doc:mode-apply', _.bind(this.onDocModeApply, this)); - Common.Gateway.on('refreshfile', _.bind(this.onRefreshFile, this)); - this.api.asc_registerCallback('asc_onRequestRefreshFile', _.bind(this.onRequestRefreshFile, this)); - this.isShowOpenDialog = false; // Initialize api gateway @@ -516,6 +513,11 @@ define([ this.appOptions.wopi = this.editorConfig.wopi; appHeader.setWopi(this.appOptions.wopi); + if (this.editorConfig.canRequestRefreshFile) { + Common.Gateway.on('refreshfile', _.bind(this.onRefreshFile, this)); + this.api.asc_registerCallback('asc_onRequestRefreshFile', _.bind(this.onRequestRefreshFile, this)); + } + Common.Controllers.Desktop.init(this.appOptions); Common.UI.HintManager.setMode(this.appOptions); }, diff --git a/apps/pdfeditor/main/app/controller/Main.js b/apps/pdfeditor/main/app/controller/Main.js index 4819ef298a..1c46d4d797 100644 --- a/apps/pdfeditor/main/app/controller/Main.js +++ b/apps/pdfeditor/main/app/controller/Main.js @@ -195,9 +195,6 @@ define([ Common.NotificationCenter.on('editing:disable', _.bind(this.onEditingDisable, this)); Common.NotificationCenter.on('pdf:mode-apply', _.bind(this.onPdfModeApply, this)); - Common.Gateway.on('refreshfile', _.bind(this.onRefreshFile, this)); - this.api.asc_registerCallback('asc_onRequestRefreshFile', _.bind(this.onRequestRefreshFile, this)); - this.isShowOpenDialog = false; // Initialize api gateway @@ -437,6 +434,11 @@ define([ this.appOptions.wopi = this.editorConfig.wopi; appHeader.setWopi(this.appOptions.wopi); + if (this.editorConfig.canRequestRefreshFile) { + Common.Gateway.on('refreshfile', _.bind(this.onRefreshFile, this)); + this.api.asc_registerCallback('asc_onRequestRefreshFile', _.bind(this.onRequestRefreshFile, this)); + } + Common.Controllers.Desktop.init(this.appOptions); Common.UI.HintManager.setMode(this.appOptions); }, diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index 2aa2604ec7..7851199dd9 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -238,8 +238,6 @@ define([ Common.NotificationCenter.on('showerror', _.bind(this.onError, this)); Common.NotificationCenter.on('markfavorite', _.bind(this.markFavorite, this)); Common.NotificationCenter.on('editing:disable', _.bind(this.onEditingDisable, this)); - Common.Gateway.on('refreshfile', _.bind(this.onRefreshFile, this)); - this.api.asc_registerCallback('asc_onRequestRefreshFile', _.bind(this.onRequestRefreshFile, this)); this.isShowOpenDialog = false; @@ -482,6 +480,11 @@ define([ this.appOptions.wopi = this.editorConfig.wopi; appHeader.setWopi(this.appOptions.wopi); + if (this.editorConfig.canRequestRefreshFile) { + Common.Gateway.on('refreshfile', _.bind(this.onRefreshFile, this)); + this.api.asc_registerCallback('asc_onRequestRefreshFile', _.bind(this.onRequestRefreshFile, this)); + } + Common.Controllers.Desktop.init(this.appOptions); Common.UI.HintManager.setMode(this.appOptions); }, diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 2c6b8294f2..4e4acd9f92 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -253,8 +253,6 @@ define([ Common.NotificationCenter.on('protect:check', _.bind(this.checkProtectedRange, this)); Common.NotificationCenter.on('editing:disable', _.bind(this.onEditingDisable, this)); Common.NotificationCenter.on('showerror', _.bind(this.onError, this)); - Common.Gateway.on('refreshfile', _.bind(this.onRefreshFile, this)); - this.api.asc_registerCallback('asc_onRequestRefreshFile', _.bind(this.onRequestRefreshFile, this)); this.stackLongActions = new Common.IrregularStack({ strongCompare : this._compareActionStrong, @@ -551,6 +549,11 @@ define([ this.appOptions.wopi = this.editorConfig.wopi; this.headerView.setWopi(this.appOptions.wopi); + if (this.editorConfig.canRequestRefreshFile) { + Common.Gateway.on('refreshfile', _.bind(this.onRefreshFile, this)); + this.api.asc_registerCallback('asc_onRequestRefreshFile', _.bind(this.onRequestRefreshFile, this)); + } + this.isFrameClosed = (this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge || this.appOptions.isEditOle); Common.Controllers.Desktop.init(this.appOptions);