Skip to content

Commit

Permalink
recode channeljoined
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Jaros committed Apr 6, 2023
1 parent b1643df commit 327f675
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions back/nest_project/src/chat/chat.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export class ChatService {
await this.channelService.delUser(userId, channelId);
let socketMap = roomHandler.userMap.get(userId);
if (socketMap != undefined) {
socketMap.emit("leaveChannel", channelId);
let channel: IChannelToEmit = await this.channelService.getOneById(channelId);
socketMap.sockets.forEach((user, socket) => {
socket.emit("channelLeaved", channel);
Expand Down Expand Up @@ -253,7 +252,8 @@ export class ChatService {
let room = roomHandler.roomMap.of(channel.id);
if (room != undefined)
room.emit("newUserInChannel", user.id, user.login);
roomHandler.emitToUserHavingThisSocket(client, "channelJoined", channel.id, channel.name);
let channelToEmit: IChannelToEmit = channel;
roomHandler.emitToUserHavingThisSocket(client, "channelJoined", {channel: channelToEmit, status: "normal"});
this.changeLocEvent(client, user, data.channelId, true, roomHandler);
})
}
Expand Down Expand Up @@ -291,8 +291,9 @@ export class ChatService {
if (logged != undefined) {
this.channelService.getOneById(channelId)
.then((channelEntity) => {
let channelToEmit: IChannelToEmit = channelEntity;
logged.sockets.forEach(({}, socket) => {
socket.emit("channelJoined", channelEntity.id, channelEntity.name);
socket.emit("channelJoined", {channel: channelToEmit, status: "normal"});
})
})
}
Expand Down Expand Up @@ -326,8 +327,9 @@ export class ChatService {
room.emit("newUserInChannel", userEntity.id, userEntity.login);
let logged = roomHandler.userMap.get(userToInvite);
if (logged != undefined) {
let channelToEmit: IChannelToEmit = chanOpts;
logged.sockets.forEach(({}, socket) => {
socket.emit("channelJoined", chanOpts.id, chanOpts.name);
socket.emit("channelJoined", {channel: channelToEmit, status: "normal"});
})
}
})
Expand Down

0 comments on commit 327f675

Please sign in to comment.