Fix spreadsheets issues when using multiple sheets
This commit is contained in:
parent
4abed38bb1
commit
ea54dd7392
@ -217,6 +217,26 @@ define([
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Loading a checkpoint reorder the sheet starting from ID "5".
|
||||||
|
// We have to reorder it manually when a checkpoint is created
|
||||||
|
// so that the messages we send to the realtime channel are
|
||||||
|
// loadable by users joining after the checkpoint
|
||||||
|
var fixSheets = function () {
|
||||||
|
try {
|
||||||
|
var editor = window.frames[0].editor;
|
||||||
|
var s = editor.GetSheets();
|
||||||
|
if (s.length === 0) { return; }
|
||||||
|
var wb = s[0].worksheet.workbook;
|
||||||
|
s.forEach(function (obj, i) {
|
||||||
|
var id = String(i + 5);
|
||||||
|
obj.worksheet.Id = id;
|
||||||
|
wb.aWorksheetsById[id] = obj.worksheet;
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
var fmConfig = {
|
var fmConfig = {
|
||||||
noHandlers: true,
|
noHandlers: true,
|
||||||
noStore: true,
|
noStore: true,
|
||||||
@ -237,6 +257,9 @@ define([
|
|||||||
oldHashes = JSON.parse(JSON.stringify(content.hashes));
|
oldHashes = JSON.parse(JSON.stringify(content.hashes));
|
||||||
content.saveLock = undefined;
|
content.saveLock = undefined;
|
||||||
APP.onLocal();
|
APP.onLocal();
|
||||||
|
APP.realtime.onSettle(function () {
|
||||||
|
fixSheets();
|
||||||
|
});
|
||||||
sframeChan.query('Q_OO_COMMAND', {
|
sframeChan.query('Q_OO_COMMAND', {
|
||||||
cmd: 'UPDATE_HASH',
|
cmd: 'UPDATE_HASH',
|
||||||
data: ev.hash
|
data: ev.hash
|
||||||
@ -891,6 +914,7 @@ define([
|
|||||||
|
|
||||||
openRtChannel(function () {
|
openRtChannel(function () {
|
||||||
setMyId();
|
setMyId();
|
||||||
|
oldHashes = JSON.parse(JSON.stringify(content.hashes));
|
||||||
loadDocument(newDoc);
|
loadDocument(newDoc);
|
||||||
initializing = false;
|
initializing = false;
|
||||||
setEditable(!readOnly);
|
setEditable(!readOnly);
|
||||||
@ -910,11 +934,13 @@ define([
|
|||||||
if (content.hashes) {
|
if (content.hashes) {
|
||||||
var latest = getLastCp(true);
|
var latest = getLastCp(true);
|
||||||
var newLatest = getLastCp();
|
var newLatest = getLastCp();
|
||||||
if (newLatest.index >= latest.index) {
|
if (newLatest.index > latest.index) {
|
||||||
|
fixSheets();
|
||||||
sframeChan.query('Q_OO_SAVE', {
|
sframeChan.query('Q_OO_SAVE', {
|
||||||
url: newLatest.file
|
url: newLatest.file
|
||||||
}, function () { });
|
}, function () { });
|
||||||
}
|
}
|
||||||
|
oldHashes = JSON.parse(JSON.stringify(content.hashes));
|
||||||
}
|
}
|
||||||
if (content.ids) {
|
if (content.ids) {
|
||||||
handleNewIds(oldIds, content.ids);
|
handleNewIds(oldIds, content.ids);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user