Skip to content

Commit

Permalink
feat: try to read room info first before join room (#403)
Browse files Browse the repository at this point in the history
  • Loading branch information
noracami authored Jul 28, 2024
1 parent ce7ddf7 commit f9e4097
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions containers/room/RoomListView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
RoomType,
getRooms,
postRoomEntry,
getRoomInfoEndpoint,
} from "@/requests/rooms";
import Button from "@/components/shared/Button";
import RoomCard from "@/components/rooms/RoomCard";
Expand Down Expand Up @@ -74,6 +75,11 @@ const RoomsListView: FC<Props> = ({ status }) => {
async function fetchRoomEntry(_roomId: string) {
setIsLoading(true);

if (await fetch(getRoomInfoEndpoint(_roomId)).catch(() => {})) {
router.push(`/rooms/${_roomId}`);
return;
}

fetch(postRoomEntry(_roomId, passwordValues.join("")))
.then(() => {
router.push(`/rooms/${_roomId}`);
Expand Down

0 comments on commit f9e4097

Please sign in to comment.