From a61ba5c1c1ca696c48acb3b9388784cba8e60d9b Mon Sep 17 00:00:00 2001 From: ker ker Date: Sun, 28 Jul 2024 16:35:09 +0800 Subject: [PATCH] feat: try to read room info first before join room --- containers/room/RoomListView.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/containers/room/RoomListView.tsx b/containers/room/RoomListView.tsx index 80ec29c4..c0fb30f9 100644 --- a/containers/room/RoomListView.tsx +++ b/containers/room/RoomListView.tsx @@ -9,6 +9,7 @@ import { RoomType, getRooms, postRoomEntry, + getRoomInfoEndpoint, } from "@/requests/rooms"; import Button from "@/components/shared/Button"; import RoomCard from "@/components/rooms/RoomCard"; @@ -74,6 +75,11 @@ const RoomsListView: FC = ({ 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}`);