Disconnect other tabs when migrating the drive

This commit is contained in:
yflory
2017-06-09 12:23:28 +02:00
parent 51e0d40572
commit f8c69573fd
3 changed files with 20 additions and 3 deletions

View File

@@ -275,7 +275,6 @@ define([
&& !drive['filesData']) { && !drive['filesData']) {
Cryptpad.getLegacyPads(function (err, data) { Cryptpad.getLegacyPads(function (err, data) {
drive[Cryptpad.oldStorageKey] = data; drive[Cryptpad.oldStorageKey] = data;
console.log(drive);
onReady(f, rt.proxy, Cryptpad, exp); onReady(f, rt.proxy, Cryptpad, exp);
}); });
return; return;
@@ -291,6 +290,15 @@ define([
} }
return; 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");
}
}); });
}; };

View File

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

View File

@@ -2503,6 +2503,12 @@ define([
} }
module.resetTree(); module.resetTree();
return false; 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 () { $iframe.find('#tree').mousedown(function () {
@@ -2731,11 +2737,11 @@ define([
Cryptpad.removeLoadingScreen(); Cryptpad.removeLoadingScreen();
}); });
}; };
var onDisconnect = function () { var onDisconnect = APP.onDisconnect = function (noAlert) {
setEditable(false); setEditable(false);
if (APP.refresh) { APP.refresh(); } if (APP.refresh) { APP.refresh(); }
APP.toolbar.failed(); APP.toolbar.failed();
Cryptpad.alert(Messages.common_connectionLost, undefined, true); if (!noAlert) { Cryptpad.alert(Messages.common_connectionLost, undefined, true); }
}; };
var onReconnect = function (info) { var onReconnect = function (info) {
setEditable(true); setEditable(true);