diff --git a/backend/src/chat/chat.gateway.ts b/backend/src/chat/chat.gateway.ts index 3c3340c2..492e4c43 100644 --- a/backend/src/chat/chat.gateway.ts +++ b/backend/src/chat/chat.gateway.ts @@ -397,9 +397,11 @@ export class ChatGateway async demoteToMember( @MessageBody('user') user: string, @MessageBody('chatId', new ParseIntPipe()) chatId: number, + @ConnectedSocket() client: Socket, ) { + const login = client.handshake.auth?.user?.login; const member = await this.chatService.getMemberFromChat(chatId, user); - const you = await this.chatService.getMemberFromChat(chatId, user); + const you = await this.chatService.getMemberFromChat(chatId, login); if (!member || !you) { this.logger.error('User not found'); return; diff --git a/frontend/src/components/Chat/ChatUsersChannelPopOver.tsx b/frontend/src/components/Chat/ChatUsersChannelPopOver.tsx index d1a85fd1..3a8e7129 100644 --- a/frontend/src/components/Chat/ChatUsersChannelPopOver.tsx +++ b/frontend/src/components/Chat/ChatUsersChannelPopOver.tsx @@ -43,6 +43,7 @@ export default function ChatUsersChannelPopOver({ modifiers: [{ name: "arrow", options: { element: arrowElement } }], placement: "left", }); + // import user from useContext but rename it as currentUser const { user: currentUser, setUpdate } = useContext(ChatContext); @@ -247,7 +248,6 @@ export default function ChatUsersChannelPopOver({ /> ) /*TODO: Make this command responsive */ } - { user.role !== "MEMBER" && ( (0); const [users, setUsers] = useState([]); const [isLoading, setIsLoading] = useState(true); - + const myUserList = users.filter(usr => usr.userLogin === user.login); + const myUser = myUserList[0] || null; chatService.socket?.on("listMessages", (messages: Message[]) => { setMessages(() => messages); @@ -61,6 +62,8 @@ export function OpenChannel() { }); const handleSendMessage = () => { + if (myUser && myUser.status === 'MUTED') + return; chatService.socket?.emit("message", { chatId: selectedChat.id, content: message, @@ -204,13 +207,13 @@ export function OpenChannel() { } }} /> - - + ); }