[FIX] Batch server deletion on logout (#1382)
This commit is contained in:
parent
447b48360f
commit
6f95bb0d17
|
@ -430,8 +430,13 @@ const RocketChat = {
|
|||
const serversDB = database.servers;
|
||||
await serversDB.action(async() => {
|
||||
const usersCollection = serversDB.collections.get('users');
|
||||
const user = await usersCollection.find(userId);
|
||||
await user.destroyPermanently();
|
||||
const userRecord = await usersCollection.find(userId);
|
||||
const serverCollection = serversDB.collections.get('servers');
|
||||
const serverRecord = await serverCollection.find(server);
|
||||
await serversDB.batch(
|
||||
userRecord.prepareDestroyPermanently(),
|
||||
serverRecord.prepareDestroyPermanently()
|
||||
);
|
||||
});
|
||||
} catch (error) {
|
||||
// Do nothing
|
||||
|
|
|
@ -130,16 +130,9 @@ const handleLogout = function* handleLogout() {
|
|||
const serversDB = database.servers;
|
||||
// all servers
|
||||
const serversCollection = serversDB.collections.get('servers');
|
||||
|
||||
// filter logging out server and delete it
|
||||
yield serversDB.action(async() => {
|
||||
const serverRecord = await serversCollection.find(server);
|
||||
await serverRecord.destroyPermanently();
|
||||
});
|
||||
|
||||
const servers = yield serversCollection.query().fetch();
|
||||
|
||||
// see if there's other logged in servers and selects first one
|
||||
// see if there're other logged in servers and selects first one
|
||||
if (servers.length > 0) {
|
||||
const newServer = servers[0].id;
|
||||
const token = yield RNUserDefaults.get(`${ RocketChat.TOKEN_KEY }-${ newServer }`);
|
||||
|
|
Loading…
Reference in New Issue