PadMessageHandler: Invert condition to improve readability

pull/5255/head
Richard Hansen 2021-10-29 22:49:11 -04:00
parent a3b4d985ac
commit 7522d76c40
1 changed files with 31 additions and 39 deletions

View File

@ -126,13 +126,9 @@ exports.kickSessionsFromPad = (padID) => {
*/
exports.handleDisconnect = async (socket) => {
stats.meter('disconnects').mark();
// save the padname of this session
const session = sessioninfos[socket.id];
// if this connection was already etablished with a handshake,
// send a disconnect message to the others
if (session && session.author) {
delete sessioninfos[socket.id];
if (!session || !session.author) return;
const {session: {user} = {}} = socket.client.request;
/* eslint-disable prefer-template -- it doesn't support breaking across multiple lines */
accessLogger.info('[LEAVE]' +
@ -163,10 +159,6 @@ exports.handleDisconnect = async (socket) => {
// Allow plugins to hook into users leaving the pad
hooks.callAll('userLeave', session);
}
// Delete the sessioninfos entrys of this session
delete sessioninfos[socket.id];
};
/**