Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fix white screen on signup #133

Merged
merged 7 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/src/features/chats/hooks/useChats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function useChats() {
const initialChatState: ChatsState = {
chats: parseChatsToState(chatData),
members:
chatData?.members.filter((member) => member._id !== userId) || [],
chatData?.members?.filter((member) => member._id !== userId) || [],
};

dispatch(setAllChats({ chatsData: initialChatState, blockList, userId }));
Expand Down
20 changes: 9 additions & 11 deletions app/src/features/chats/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function getChatByID({

export function parseChatsToState(chatData?: any) {
if (!chatData) return [];
return chatData.chats.map((chat: any): DetailedChatInterface => {
return chatData?.chats?.map((chat: any): DetailedChatInterface => {
const { isMuted, draft, chat: currChat } = chat;
const {
_id: chatId,
Expand All @@ -25,17 +25,15 @@ export function parseChatsToState(chatData?: any) {
name,
} = currChat;

const filteredMembers = members
.map((member: any) => {
return {
_id: member.user,
Role: member.Role,
} as ChatMember;
})
const filteredMembers = members?.map((member: any) => {
return {
_id: member.user,
Role: member.Role,
} as ChatMember;
});


const incomingLastMessage = chatData.lastMessages.find(
(lastMessage: any) => lastMessage.chatId === chatId
const incomingLastMessage = chatData?.lastMessages?.find(
(lastMessage: any) => lastMessage?.chatId === chatId
)?.lastMessage;

return {
Expand Down
6 changes: 3 additions & 3 deletions app/src/state/messages/chats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ const chatsSlice = createSlice({
}>
) => {
const { blockList, userId, chatsData } = action.payload;
const incomminingChats = chatsData.chats;
const incomminingChats = chatsData?.chats;
incomminingChats
.map((chat) => {
?.map((chat) => {
if (chat.type === "private") {
const members = chat.members;
const otherUser = members.filter(
Expand All @@ -58,7 +58,7 @@ const chatsSlice = createSlice({
}
return chat;
})
.filter((chat) => chat !== undefined) as DetailedChatInterface[];
?.filter((chat) => chat !== undefined) as DetailedChatInterface[];
state.chats = incomminingChats;
state.members = action.payload.chatsData.members;
},
Expand Down
Loading