fix: leave
This commit is contained in:
parent
6687884604
commit
d10508fa05
|
@ -1,5 +1,6 @@
|
|||
import {
|
||||
channelIsAnonymous,
|
||||
parseChannel,
|
||||
parseChatChannel,
|
||||
renderChannel,
|
||||
validateChannel,
|
||||
|
@ -16,6 +17,7 @@ import Message from './packets/message.server';
|
|||
import ensureCanonical from './ensure-canonical';
|
||||
import defaultState, {channelsToHydrate} from './state';
|
||||
import joinChannel from './join-channel';
|
||||
import leaveChannel from './leave-channel';
|
||||
|
||||
export * from './state';
|
||||
|
||||
|
@ -66,6 +68,14 @@ export default {
|
|||
.filter(({type}) => 'r' === type)
|
||||
.filter((channel) => req.userId || channelIsAnonymous(channel))
|
||||
.map((channel) => joinChannel(latus, channel, socket));
|
||||
socket.on('disconnecting', async () => {
|
||||
Object.keys(socket.rooms).forEach((room) => {
|
||||
const parsed = parseChannel(room);
|
||||
if (parsed && 'r' === parsed.type) {
|
||||
leaveChannel(parsed, socket);
|
||||
}
|
||||
});
|
||||
});
|
||||
return Promise.all(joins);
|
||||
},
|
||||
'@reddichat/state/defaultState': async (req, latus) => ({
|
||||
|
|
Loading…
Reference in New Issue
Block a user