Disconnect other tabs when migrating the drive

pull/1/head
yflory 8 years ago
parent 51e0d40572
commit f8c69573fd

@ -275,7 +275,6 @@ define([
&& !drive['filesData']) {
Cryptpad.getLegacyPads(function (err, data) {
drive[Cryptpad.oldStorageKey] = data;
console.log(drive);
onReady(f, rt.proxy, Cryptpad, exp);
});
return;
@ -291,6 +290,15 @@ define([
}
return;
}
})
.on('change', ['drive'], function () {
var path = arguments[2];
var value = arguments[1];
if (path[1] === "migrate" && value === 1) {
rt.network.disconnect();
rt.realtime.abort();
Cryptpad.alert("Disconnected while migration");
}
});
};

@ -914,6 +914,7 @@ define([
var migrateToNewFormat = function () {
if (!files[OLD_FILES_DATA]) { return; }
try {
files.migrate = 1;
var oldData = files[OLD_FILES_DATA].slice();
if (!files[FILES_DATA]) {
files[FILES_DATA] = {};
@ -953,6 +954,8 @@ define([
});
files[OLD_FILES_DATA] = undefined;
delete files[OLD_FILES_DATA];
files.migrate = undefined;
delete files.migrate;
} catch(e) {
console.error(e);
}

@ -2503,6 +2503,12 @@ define([
}
module.resetTree();
return false;
}).on('change', ['drive', 'migrate'], function () {
var path = arguments[2];
var value = arguments[1];
if (path[1] === "migrate" && value === 1) {
if (APP.onDisconnect) { APP.onDisconnect(true); }
}
});
$iframe.find('#tree').mousedown(function () {
@ -2731,11 +2737,11 @@ define([
Cryptpad.removeLoadingScreen();
});
};
var onDisconnect = function () {
var onDisconnect = APP.onDisconnect = function (noAlert) {
setEditable(false);
if (APP.refresh) { APP.refresh(); }
APP.toolbar.failed();
Cryptpad.alert(Messages.common_connectionLost, undefined, true);
if (!noAlert) { Cryptpad.alert(Messages.common_connectionLost, undefined, true); }
};
var onReconnect = function (info) {
setEditable(true);

Loading…
Cancel
Save