Refresh file on reconnect

This commit is contained in:
Julia Radzhabova 2022-12-09 14:22:18 +03:00
parent 3ddbc065e9
commit f34273ed89
3 changed files with 42 additions and 1 deletions

View file

@ -752,6 +752,13 @@
}); });
}; };
var _refreshFile = function(data) {
_sendCommand({
command: 'refreshFile',
data: data
});
};
var _serviceCommand = function(command, data) { var _serviceCommand = function(command, data) {
_sendCommand({ _sendCommand({
command: 'internalCommand', command: 'internalCommand',
@ -787,7 +794,8 @@
requestClose : _requestClose, requestClose : _requestClose,
grabFocus : _grabFocus, grabFocus : _grabFocus,
blurFocus : _blurFocus, blurFocus : _blurFocus,
setReferenceData : _setReferenceData setReferenceData : _setReferenceData,
refreshFile : _refreshFile
} }
}; };

View file

@ -142,6 +142,10 @@ if (window.Common === undefined) {
'setReferenceData': function(data) { 'setReferenceData': function(data) {
$me.trigger('setreferencedata', data); $me.trigger('setreferencedata', data);
},
'refreshFile': function(data) {
$me.trigger('refreshfile', data);
} }
}; };
@ -359,6 +363,10 @@ if (window.Common === undefined) {
_postMessage({ event: 'onPluginsReady' }); _postMessage({ event: 'onPluginsReady' });
}, },
requestRefreshFile: function() {
_postMessage({ event: 'onRequestRefreshFile' });
},
on: function(event, handler){ on: function(event, handler){
var localHandler = function(event, data){ var localHandler = function(event, data){
handler.call(me, data) handler.call(me, data)

View file

@ -226,6 +226,9 @@ define([
Common.NotificationCenter.on('showerror', _.bind(this.onError, this)); Common.NotificationCenter.on('showerror', _.bind(this.onError, this));
Common.NotificationCenter.on('editing:disable', _.bind(this.onEditingDisable, 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; this.isShowOpenDialog = false;
// Initialize api gateway // Initialize api gateway
@ -2995,6 +2998,28 @@ define([
} }
}, },
onRequestRefreshFile: function() {
Common.Gateway.requestRefreshFile();
},
onRefreshFile: function(data) {
if (data) {
var docInfo = new Asc.asc_CDocInfo();
if (data.document) {
docInfo.put_Id(data.document.key);
docInfo.put_Url(data.document.url);
docInfo.put_Title(data.document.title);
data.document.title && Common.Gateway.metaChange({title: data.document.title});
}
if (data.editorConfig) {
docInfo.put_CallbackUrl(data.editorConfig.callbackUrl);
}
if (data.token)
docInfo.put_Token(data.token);
this.api.asc_setDocInfo(docInfo);
}
},
leavePageText: 'You have unsaved changes in this document. Click \'Stay on this Page\' then \'Save\' to save them. Click \'Leave this Page\' to discard all the unsaved changes.', leavePageText: 'You have unsaved changes in this document. Click \'Stay on this Page\' then \'Save\' to save them. Click \'Leave this Page\' to discard all the unsaved changes.',
criticalErrorTitle: 'Error', criticalErrorTitle: 'Error',
notcriticalErrorTitle: 'Warning', notcriticalErrorTitle: 'Warning',