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) {
if (!newObj.docId) {
return;
}
if (this.isCoAuthoringEnable) {
this.asc_coAuthoringDisconnect();
}
var bUpdate = true;
if (null === this.VersionHistory) {
......@@ -87,8 +84,12 @@ AscCommon.baseEditorsApi.prototype.asc_showRevision = function(newObj) {
this.DocInfo.put_Id(this.VersionHistory.docId);
this.DocInfo.put_Url(this.VersionHistory.url);
this.documentUrlChanges = this.VersionHistory.urlChanges;
this.VersionHistoryOpen = true;
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) {
// Нужно только добавить некоторые изменения
AscCommon.CollaborativeEditing.Clear_CollaborativeMarks();
......
......@@ -96,6 +96,7 @@ function baseEditorsApi(name, editorId) {
// Version History
this.VersionHistory = null; // Объект, который отвечает за точку в списке версий
this.VersionHistoryOpen = false;
//Флаги для применения свойств через слайдеры
this.noCreatePoint = false;
......@@ -413,8 +414,17 @@ baseEditorsApi.prototype._coAuthoringInit = function() {
t.asyncServerIdEndLoaded();
};
this.CoAuthoringApi.onFirstConnect = function() {
t.isOnFirstConnectEnd = true;
t._onEndPermissions();
if (t.isOnFirstConnectEnd) {
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) {
t.licenseResult = res;
......
......@@ -267,9 +267,9 @@
}
};
CDocsCoApi.prototype.disconnect = function() {
CDocsCoApi.prototype.disconnect = function(isRealDisconnect) {
if (this._CoAuthoringApi && this._onlineWork) {
this._CoAuthoringApi.disconnect();
this._CoAuthoringApi.disconnect(isRealDisconnect);
}
};
......@@ -434,7 +434,6 @@
this._countUsers = 0;
this.isLicenseInit = false;
this.isAuthInit = false;
this._locks = {};
this._msgBuffer = [];
this._lockCallbacks = {};
......@@ -696,11 +695,15 @@
}
};
DocsCoApi.prototype.disconnect = function() {
DocsCoApi.prototype.disconnect = function(isRealDisconnect) {
// Отключаемся сами
this.isCloseCoAuthoring = true;
if (isRealDisconnect) {
this.sockjs.close();
} else {
this._send({"type": "close"});
this._state = ConnectionState.ClosedCoAuth;
}
};
DocsCoApi.prototype.openDocument = function(data) {
......@@ -1149,29 +1152,30 @@
DocsCoApi.prototype.init = function(user, docid, documentCallbackUrl, token, editorType, documentFormatSave) {
this._user = user;
this._docid = docid;
this._docid = null;
this._documentCallbackUrl = documentCallbackUrl;
this._token = token;
this.ownedLockBlocks = [];
this.sockjs_url = '/doc/' + docid + '/c';
this.sockjs_url = null;
this.editorType = editorType;
this._isExcel = c_oEditorId.Spreadsheet === editorType;
this._isPresentation = c_oEditorId.Presentation === editorType;
this._isAuth = false;
this._documentFormatSave = documentFormatSave;
this.setDocId(docid);
this._initSocksJs();
};
DocsCoApi.prototype.getDocId = function() {
return this._docid;
};
DocsCoApi.prototype.setDocId = function(docId) {
DocsCoApi.prototype.setDocId = function(docid) {
//todo возможно надо менять sockjs_url
this._docid = docId;
this._docid = docid;
this.sockjs_url = '/doc/' + docid + '/c';
};
// Авторизация (ее нужно делать после выставления состояния редактора view-mode)
DocsCoApi.prototype.auth = function(isViewer, opt_openCmd) {
this.isAuthInit = true;
this._isViewer = isViewer;
if (this._locks) {
this.ownedLockBlocks = [];
......@@ -1219,11 +1223,7 @@
}
t._state = ConnectionState.WaitAuth;
if (t.isAuthInit) {
t.auth(t._isViewer);
} else {
t.onFirstConnect();
}
};
sockjs.onmessage = function(e) {
//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