Commit 328cf157 authored by konovalovsergey's avatar konovalovsergey Committed by Alexander.Trofimov

real disconnect in versionHistory for gc

parent 59517edd
...@@ -70,9 +70,6 @@ AscCommon.baseEditorsApi.prototype.asc_showRevision = function(newObj) { ...@@ -70,9 +70,6 @@ AscCommon.baseEditorsApi.prototype.asc_showRevision = function(newObj) {
if (!newObj.docId) { if (!newObj.docId) {
return; return;
} }
if (this.isCoAuthoringEnable) {
this.asc_coAuthoringDisconnect();
}
var bUpdate = true; var bUpdate = true;
if (null === this.VersionHistory) { if (null === this.VersionHistory) {
...@@ -87,8 +84,12 @@ AscCommon.baseEditorsApi.prototype.asc_showRevision = function(newObj) { ...@@ -87,8 +84,12 @@ AscCommon.baseEditorsApi.prototype.asc_showRevision = function(newObj) {
this.DocInfo.put_Id(this.VersionHistory.docId); this.DocInfo.put_Id(this.VersionHistory.docId);
this.DocInfo.put_Url(this.VersionHistory.url); this.DocInfo.put_Url(this.VersionHistory.url);
this.documentUrlChanges = this.VersionHistory.urlChanges; this.documentUrlChanges = this.VersionHistory.urlChanges;
this.VersionHistoryOpen = true;
this.asc_setDocInfo(this.DocInfo); this.asc_setDocInfo(this.DocInfo);
this.asc_LoadDocument(true); this.asc_setViewMode(true);
//делаем disconnect и reconnect, чтобы docId соединения и документа совпадали, иначе будут проблемы со сборшиком мусора
this.CoAuthoringApi.disconnect(true);
} else if (this.VersionHistory.currentChangeId < newObj.currentChangeId) { } else if (this.VersionHistory.currentChangeId < newObj.currentChangeId) {
// Нужно только добавить некоторые изменения // Нужно только добавить некоторые изменения
AscCommon.CollaborativeEditing.Clear_CollaborativeMarks(); AscCommon.CollaborativeEditing.Clear_CollaborativeMarks();
......
...@@ -96,6 +96,7 @@ function baseEditorsApi(name, editorId) { ...@@ -96,6 +96,7 @@ function baseEditorsApi(name, editorId) {
// Version History // Version History
this.VersionHistory = null; // Объект, который отвечает за точку в списке версий this.VersionHistory = null; // Объект, который отвечает за точку в списке версий
this.VersionHistoryOpen = false;
//Флаги для применения свойств через слайдеры //Флаги для применения свойств через слайдеры
this.noCreatePoint = false; this.noCreatePoint = false;
...@@ -413,8 +414,17 @@ baseEditorsApi.prototype._coAuthoringInit = function() { ...@@ -413,8 +414,17 @@ baseEditorsApi.prototype._coAuthoringInit = function() {
t.asyncServerIdEndLoaded(); t.asyncServerIdEndLoaded();
}; };
this.CoAuthoringApi.onFirstConnect = function() { this.CoAuthoringApi.onFirstConnect = function() {
t.isOnFirstConnectEnd = true; if (t.isOnFirstConnectEnd) {
t._onEndPermissions(); if (t.VersionHistoryOpen) {
t.VersionHistoryOpen = false;
t.asc_LoadDocument(true);
} else {
t.CoAuthoringApi.auth(t.getViewMode());
}
} else {
t.isOnFirstConnectEnd = true;
t._onEndPermissions();
}
}; };
this.CoAuthoringApi.onLicense = function(res) { this.CoAuthoringApi.onLicense = function(res) {
t.licenseResult = res; t.licenseResult = res;
......
...@@ -267,9 +267,9 @@ ...@@ -267,9 +267,9 @@
} }
}; };
CDocsCoApi.prototype.disconnect = function() { CDocsCoApi.prototype.disconnect = function(isRealDisconnect) {
if (this._CoAuthoringApi && this._onlineWork) { if (this._CoAuthoringApi && this._onlineWork) {
this._CoAuthoringApi.disconnect(); this._CoAuthoringApi.disconnect(isRealDisconnect);
} }
}; };
...@@ -434,7 +434,6 @@ ...@@ -434,7 +434,6 @@
this._countUsers = 0; this._countUsers = 0;
this.isLicenseInit = false; this.isLicenseInit = false;
this.isAuthInit = false;
this._locks = {}; this._locks = {};
this._msgBuffer = []; this._msgBuffer = [];
this._lockCallbacks = {}; this._lockCallbacks = {};
...@@ -696,11 +695,15 @@ ...@@ -696,11 +695,15 @@
} }
}; };
DocsCoApi.prototype.disconnect = function() { DocsCoApi.prototype.disconnect = function(isRealDisconnect) {
// Отключаемся сами // Отключаемся сами
this.isCloseCoAuthoring = true; this.isCloseCoAuthoring = true;
if (isRealDisconnect) {
this.sockjs.close();
} else {
this._send({"type": "close"}); this._send({"type": "close"});
this._state = ConnectionState.ClosedCoAuth; this._state = ConnectionState.ClosedCoAuth;
}
}; };
DocsCoApi.prototype.openDocument = function(data) { DocsCoApi.prototype.openDocument = function(data) {
...@@ -1149,29 +1152,30 @@ ...@@ -1149,29 +1152,30 @@
DocsCoApi.prototype.init = function(user, docid, documentCallbackUrl, token, editorType, documentFormatSave) { DocsCoApi.prototype.init = function(user, docid, documentCallbackUrl, token, editorType, documentFormatSave) {
this._user = user; this._user = user;
this._docid = docid; this._docid = null;
this._documentCallbackUrl = documentCallbackUrl; this._documentCallbackUrl = documentCallbackUrl;
this._token = token; this._token = token;
this.ownedLockBlocks = []; this.ownedLockBlocks = [];
this.sockjs_url = '/doc/' + docid + '/c'; this.sockjs_url = null;
this.editorType = editorType; this.editorType = editorType;
this._isExcel = c_oEditorId.Spreadsheet === editorType; this._isExcel = c_oEditorId.Spreadsheet === editorType;
this._isPresentation = c_oEditorId.Presentation === editorType; this._isPresentation = c_oEditorId.Presentation === editorType;
this._isAuth = false; this._isAuth = false;
this._documentFormatSave = documentFormatSave; this._documentFormatSave = documentFormatSave;
this.setDocId(docid);
this._initSocksJs(); this._initSocksJs();
}; };
DocsCoApi.prototype.getDocId = function() { DocsCoApi.prototype.getDocId = function() {
return this._docid; return this._docid;
}; };
DocsCoApi.prototype.setDocId = function(docId) { DocsCoApi.prototype.setDocId = function(docid) {
//todo возможно надо менять sockjs_url //todo возможно надо менять sockjs_url
this._docid = docId; this._docid = docid;
this.sockjs_url = '/doc/' + docid + '/c';
}; };
// Авторизация (ее нужно делать после выставления состояния редактора view-mode) // Авторизация (ее нужно делать после выставления состояния редактора view-mode)
DocsCoApi.prototype.auth = function(isViewer, opt_openCmd) { DocsCoApi.prototype.auth = function(isViewer, opt_openCmd) {
this.isAuthInit = true;
this._isViewer = isViewer; this._isViewer = isViewer;
if (this._locks) { if (this._locks) {
this.ownedLockBlocks = []; this.ownedLockBlocks = [];
...@@ -1219,11 +1223,7 @@ ...@@ -1219,11 +1223,7 @@
} }
t._state = ConnectionState.WaitAuth; t._state = ConnectionState.WaitAuth;
if (t.isAuthInit) {
t.auth(t._isViewer);
} else {
t.onFirstConnect(); t.onFirstConnect();
}
}; };
sockjs.onmessage = function(e) { sockjs.onmessage = function(e) {
//TODO: add checks and error handling //TODO: add checks and error handling
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment