Fix OO locks when reloading a page within the same worker

pull/1/head
yflory 4 years ago
parent 3496862ed9
commit 193ea3033e

@ -213,6 +213,19 @@ define([
} }
}; };
// Make sure a former tab on the same worker doesn't have remaining locks
var checkClients = function (clients) {
Object.keys(content.ids).forEach(function (id) {
var tabId = Number(id.slice(33)); // remove the netflux ID and the "-"
if (clients.indexOf(tabId) === -1) {
removeClient({
id: tabId
});
}
});
};
var getFileType = function () { var getFileType = function () {
var type = common.getMetadataMgr().getPrivateData().ooType; var type = common.getMetadataMgr().getPrivateData().ooType;
var title = common.getMetadataMgr().getMetadataLazy().title; var title = common.getMetadataMgr().getMetadataLazy().title;
@ -728,6 +741,7 @@ define([
sframeChan.on('EV_OO_EVENT', function (obj) { sframeChan.on('EV_OO_EVENT', function (obj) {
switch (obj.ev) { switch (obj.ev) {
case 'READY': case 'READY':
checkClients(obj.data);
cb(); cb();
break; break;
case 'LEAVE': case 'LEAVE':
@ -1357,6 +1371,7 @@ define([
} catch (e) {} } catch (e) {}
} else { } else {
setEditable(true); setEditable(true);
handleNewLocks({}, content.locks);
if (APP.unsavedChanges) { if (APP.unsavedChanges) {
var unsaved = APP.unsavedChanges; var unsaved = APP.unsavedChanges;
delete APP.unsavedChanges; delete APP.unsavedChanges;

@ -40,7 +40,7 @@ define([
if (!c.id) { c.id = chan.wc.myID + '-' + client; } if (!c.id) { c.id = chan.wc.myID + '-' + client; }
getHistory(ctx, client, function () { getHistory(ctx, client, function () {
ctx.emit('READY', '', [client]); ctx.emit('READY', chan.clients, [client]);
}); });
// ==> And push the new tab to the list // ==> And push the new tab to the list
@ -149,7 +149,7 @@ define([
} }
// End of history: emit READY // End of history: emit READY
if (parsed.state && parsed.state === 1 && parsed.channel) { if (parsed.state && parsed.state === 1 && parsed.channel) {
ctx.emit('READY', '', chan.clients); ctx.emit('READY', chan.clients, chan.clients);
return; return;
} }
if (parsed.error && parsed.channel) { return; } if (parsed.error && parsed.channel) { return; }

Loading…
Cancel
Save