Skip to content

Commit

Permalink
better state for selecting chat
Browse files Browse the repository at this point in the history
  • Loading branch information
Wadie-ess committed Nov 10, 2023
1 parent 654f28d commit b92e9a9
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,13 @@ export const useChatStore = create<ChatState>()((set) => ({
changeChatType: (type: ChatType) =>
set((state) => {
state.selectedChatType = type;
if (type === ChatType.Room ) {
if (type === ChatType.Room) {
state.selectedChatID = chatRooms.length > 0 ? chatRooms[0].id : "1";
} else if (type === ChatType.Chat) {
state.selectedChatID =
state.recentDms.length > 0 ? state.recentDms[0].id : "1";
state.recentDms.length > 0 &&
state.setCurrentDmUser(state.recentDms[0]);
}
return { ...state };
}),
Expand Down

0 comments on commit b92e9a9

Please sign in to comment.