fix: don't join/leave user channels

This commit is contained in:
cha0s 2020-07-25 20:02:39 -05:00
parent 7b86158a19
commit 536e9dae2e

View File

@ -57,6 +57,7 @@ export function createSocketServer(httpServer) {
socketServer.io.use(async (socket, next) => {
await Promise.all(
(await channelsToHydrate(socket.handshake))
.filter(({type}) => 'r' === type)
.map((channel) => joinChannel(channel))
.map((channel) => userJoin(channel, socket)),
);
@ -90,9 +91,12 @@ export function createSocketServer(httpServer) {
});
socket.on('disconnecting', async () => {
Object.keys(socket.socket.rooms).forEach((room) => {
if (parseChannel(`/chat${room}`)) {
const parsed = parseChannel(`/chat${room}`);
if (parsed) {
if ('r' === parsed.type) {
userLeave(room, socket);
}
}
});
});
});