Skip to content

Commit

Permalink
FIX : 채팅방 불러오는거 로그인상태에만 동작하도록
Browse files Browse the repository at this point in the history
  • Loading branch information
Jbiscode committed Jun 25, 2024
1 parent 6f5ff84 commit 55f61dc
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/hooks/chat/useGetConversations.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ const useGetConversations = () => {
const data = await response.json();
if(data.length > 0){
setConversations(data);
} else if(isLoggedin && response.status!==401){
} else if(isLoggedin && data.length === 0){
setConversations([]);
throw new Error("대화방이 없습니다.");
}else if(!isLoggedin){
setConversations([]);
throw new Error("채팅방은 로그인이 필요합니다.");
}

} catch (error) {
Expand All @@ -38,7 +40,9 @@ const useGetConversations = () => {
}

};
if(isLoggedin){
getConversation();
}
},[token ,isLoggedin]);

return { loading, conversations };
Expand Down

0 comments on commit 55f61dc

Please sign in to comment.