Fix persisting Shared Worker when logging out with multiple tabs
This commit is contained in:
parent
a5d5dba9f2
commit
66e74efb0c
4 changed files with 17 additions and 1 deletions
|
@ -387,6 +387,9 @@ define([
|
|||
cb();
|
||||
});
|
||||
};
|
||||
common.stopWorker = function () {
|
||||
postMessage('STOPWORKER', null, function () {});
|
||||
};
|
||||
common.logoutFromAll = function (cb) {
|
||||
var token = Math.floor(Math.random()*Number.MAX_SAFE_INTEGER);
|
||||
localStorage.setItem(Constants.tokenKey, token);
|
||||
|
|
|
@ -19,6 +19,7 @@ define([
|
|||
if (q === 'CONNECT') { return; }
|
||||
if (q === 'JOIN_PAD') { return; }
|
||||
if (q === 'SEND_PAD_MSG') { return; }
|
||||
if (q === 'STOPWORKER') { return; }
|
||||
chan.on(q, function (data, cb) {
|
||||
try {
|
||||
Rpc.queries[q](clientId, data, cb);
|
||||
|
@ -29,6 +30,9 @@ define([
|
|||
}
|
||||
});
|
||||
});
|
||||
chan.on('STOPWORKER', function (data, cb) {
|
||||
cb();
|
||||
});
|
||||
chan.on('CONNECT', function (cfg, cb) {
|
||||
// load Store here, with cfg, and pass a "query" (chan.query)
|
||||
// cId is a clientId used in ServiceWorker or SharedWorker
|
||||
|
|
|
@ -53,6 +53,7 @@ var init = function (client, cb) {
|
|||
if (q === 'CONNECT') { return; }
|
||||
if (q === 'JOIN_PAD') { return; }
|
||||
if (q === 'SEND_PAD_MSG') { return; }
|
||||
if (q === 'STOPWORKER') { return; }
|
||||
chan.on(q, function (data, cb) {
|
||||
try {
|
||||
Rpc.queries[q](clientId, data, cb);
|
||||
|
@ -71,6 +72,10 @@ var init = function (client, cb) {
|
|||
}
|
||||
});
|
||||
});
|
||||
chan.on('STOPWORKER', function (data, cb) {
|
||||
console.error('ICI');
|
||||
self.close();
|
||||
});
|
||||
chan.on('CONNECT', function (cfg, cb) {
|
||||
debug('SharedW connecting to store...');
|
||||
/*
|
||||
|
|
|
@ -1319,11 +1319,15 @@ define([
|
|||
});
|
||||
|
||||
sframeChan.on('Q_LOGOUT', function (data, cb) {
|
||||
Cryptpad.stopWorker();
|
||||
Utils.LocalStore.logout(cb);
|
||||
});
|
||||
|
||||
sframeChan.on('Q_LOGOUT_EVERYWHERE', function (data, cb) {
|
||||
Cryptpad.logoutFromAll(Utils.Util.bake(Utils.LocalStore.logout, cb));
|
||||
Cryptpad.logoutFromAll(Utils.Util.bake(Utils.LocalStore.logout, function () {
|
||||
Cryptpad.stopWorker();
|
||||
cb();
|
||||
}));
|
||||
});
|
||||
|
||||
sframeChan.on('EV_NOTIFY', function (data) {
|
||||
|
|
Loading…
Reference in a new issue