Commit 7651763a authored by konovalovsergey's avatar konovalovsergey

real disconnect in versionHistory for gc

parent 8dad7b43
......@@ -94,9 +94,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) {
......@@ -111,8 +108,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();
......
......@@ -120,6 +120,7 @@ function baseEditorsApi(name, editorId) {
// Version History
this.VersionHistory = null; // Объект, который отвечает за точку в списке версий
this.VersionHistoryOpen = false;
//Флаги для применения свойств через слайдеры
this.noCreatePoint = false;
......@@ -437,8 +438,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;
......
......@@ -291,9 +291,9 @@
}
};
CDocsCoApi.prototype.disconnect = function() {
CDocsCoApi.prototype.disconnect = function(isRealDisconnect) {
if (this._CoAuthoringApi && this._onlineWork) {
this._CoAuthoringApi.disconnect();
this._CoAuthoringApi.disconnect(isRealDisconnect);
}
};
......@@ -458,7 +458,6 @@
this._countUsers = 0;
this.isLicenseInit = false;
this.isAuthInit = false;
this._locks = {};
this._msgBuffer = [];
this._lockCallbacks = {};
......@@ -720,11 +719,15 @@
}
};
DocsCoApi.prototype.disconnect = function() {
DocsCoApi.prototype.disconnect = function(isRealDisconnect) {
// Отключаемся сами
this.isCloseCoAuthoring = true;
this._send({"type": "close"});
this._state = ConnectionState.ClosedCoAuth;
if (isRealDisconnect) {
this.sockjs.close();
} else {
this._send({"type": "close"});
this._state = ConnectionState.ClosedCoAuth;
}
};
DocsCoApi.prototype.openDocument = function(data) {
......@@ -1173,29 +1176,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 = [];
......@@ -1243,11 +1247,7 @@
}
t._state = ConnectionState.WaitAuth;
if (t.isAuthInit) {
t.auth(t._isViewer);
} else {
t.onFirstConnect();
}
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