Merge branch logout into 5.4-rc

This commit is contained in:
yflory 2023-07-18 15:28:30 +02:00
commit 111d1fee17
4 changed files with 17 additions and 1 deletions

View File

@ -389,6 +389,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);

View File

@ -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

View File

@ -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...');
/*

View File

@ -1343,11 +1343,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) {