PadMessageHandler: Invert condition to improve readability

This commit is contained in:
Richard Hansen 2021-10-29 22:49:11 -04:00
parent a3b4d985ac
commit 7522d76c40

View file

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