Skip to content

Commit

Permalink
Delete lingering room (Standalone bug)
Browse files Browse the repository at this point in the history
  • Loading branch information
gdbroman committed Jul 18, 2023
1 parent 9045640 commit e1271ad
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
25 changes: 14 additions & 11 deletions app/src/renderer/apps/StandaloneChat/StandaloneChatRoom.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect } from 'react';
import { MouseEvent, useEffect } from 'react';
import { observer } from 'mobx-react';

import {
Expand Down Expand Up @@ -39,6 +39,18 @@ const StandaloneChatRoomPresenter = () => {
const creatorStr =
creator.length > 14 ? `${creator.substring(0, 14)}...` : creator;

const onClickLeaveRoom = (e: MouseEvent) => {
e.stopPropagation();

chatStore.setSubroute('chat');
roomsStore.leaveRoom(rid);

// Delete room if we're the creator or the last person in the room.
if (creator === loggedInAccount?.serverId || presentCount === 0) {
roomsStore.deleteRoom(rid);
}
};

return (
<Flex flex={1} flexDirection="column" width="100%">
<Flex
Expand Down Expand Up @@ -102,16 +114,7 @@ const StandaloneChatRoomPresenter = () => {
icon="RoomLeave"
size={22}
customBg="intent-alert"
onClick={(evt) => {
evt.stopPropagation();
if (creator === loggedInAccount?.serverId) {
roomsStore.deleteRoom(rid);
chatStore.setSubroute('chat');
} else {
roomsStore.leaveRoom(rid);
chatStore.setSubroute('chat');
}
}}
onClick={onClickLeaveRoom}
/>
<CommButton
icon={isMuted ? 'MicOff' : 'MicOn'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,21 @@ const StartRoomButtonPresenter = ({ isStandaloneChat }: Props) => {
// LEAVE OTHER ROOM
sound.playRoomLeave();
roomsStore.leaveRoom(roomsStore.currentRoom.rid);
// DELETE OTHER ROOM IF EMPTY
if (roomsStore.currentRoom?.present.length === 0) {
roomsStore.deleteRoom(roomsStore.currentRoom.rid);
}
}

if (existingRoom) {
if (areWeInRoom) {
sound.playRoomLeave();
// LEAVE ROOM
sound.playRoomLeave();
roomsStore.leaveRoom(existingRoom.rid);
if (subroute === 'room') setSubroute('chat');

// DELETE ROOM IF EMPTY
if (existingRoom?.present.length === 0) {
// DELETE ROOM
roomsStore.deleteRoom(existingRoom.rid);
}
} else {
Expand Down

0 comments on commit e1271ad

Please sign in to comment.