From 2547e7a669ad8627bbf80aeea35133b0b0b0291f Mon Sep 17 00:00:00 2001 From: Mykhailo Mohyliuk Date: Fri, 11 Aug 2023 10:33:57 +0300 Subject: [PATCH] leave room --- client-web/src/components/Chat/LeaveRoomButton.tsx | 5 ++++- client-web/src/pages/ChatInRoom/Chat.tsx | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/client-web/src/components/Chat/LeaveRoomButton.tsx b/client-web/src/components/Chat/LeaveRoomButton.tsx index c490c486..7f259971 100644 --- a/client-web/src/components/Chat/LeaveRoomButton.tsx +++ b/client-web/src/components/Chat/LeaveRoomButton.tsx @@ -4,6 +4,7 @@ import LogoutIcon from "@mui/icons-material/Logout"; import { DeleteDialog } from "../DeleteDialog"; import xmpp from "../../xmpp"; import { useStoreState } from "../../store"; +import { useHistory } from "react-router"; export interface ILeaveRoomButton { roomJid: string; @@ -12,6 +13,7 @@ export interface ILeaveRoomButton { export const LeaveRoomButton: React.FC = ({ roomJid }) => { const deleteUserChatRoom = useStoreState(s => s.deleteUserChatRoom) const [showLeaveRoom, setShowLeaveRoom] = useState(false); + const history = useHistory() const onButtonClick = () => { setShowLeaveRoom(true); }; @@ -22,7 +24,8 @@ export const LeaveRoomButton: React.FC = ({ roomJid }) => { xmpp.leaveTheRoom(roomJid); xmpp.unsubscribe(roomJid); deleteUserChatRoom(roomJid) - closeLeaveRoomModal() + closeLeaveRoomModal(); + history.push('/chat/none') }; return ( <> diff --git a/client-web/src/pages/ChatInRoom/Chat.tsx b/client-web/src/pages/ChatInRoom/Chat.tsx index 56a6b104..1199587d 100644 --- a/client-web/src/pages/ChatInRoom/Chat.tsx +++ b/client-web/src/pages/ChatInRoom/Chat.tsx @@ -550,14 +550,14 @@ export function ChatInRoom() { handleCloseDeleteMessageDialog(); }; - const roomLastSeen = + const roomLastSeen =mainWindowMessages.slice(-1)[0]?.date ? messages.filter((item) => item.roomJID === currentRoom).length > 0 && "Active " + formatDistance( - subDays(new Date(mainWindowMessages.slice(-1)[0].date), 0), + subDays(new Date(mainWindowMessages.slice(-1)[0]?.date), 0), new Date(), { addSuffix: true } - ); + ) : ''; //Delete confirmation dialogue component //component to render File upload dialog box