Skip to content

Commit 6bdc73f

Browse files
committed
Refactor chatSlice: remove unused activeChatId parameter from setMessagesForChat and update message handling
1 parent ab82fdd commit 6bdc73f

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

frontend/src/statemanagement/chats/chatSlice.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ const initialState: ChatState = {
1919

2020
const setMessagesForChat = (
2121
chat: ChatRoomWithNotifications,
22-
activeChatId?: string,
2322
messagesToAdd?: ChatMessage[]
2423
) => {
2524
const { messages, noNewMessages } = createUniqueMessages(
@@ -129,11 +128,7 @@ export const chatSlice = createSlice({
129128
updateChatRoomMessagesSync: (state, action: { payload: ChatRoom }) => {
130129
const chatRoom = state.chats.find((x) => x.id == action.payload.id);
131130
if (chatRoom != null) {
132-
setMessagesForChat(
133-
chatRoom,
134-
state.activeChatId,
135-
action.payload.messages
136-
);
131+
setMessagesForChat(chatRoom, action.payload.messages);
137132
} else {
138133
state.chats.push({ ...action.payload, unreadMessages: 1 });
139134
}
@@ -165,7 +160,7 @@ export const chatSlice = createSlice({
165160
state.chatIsLoading = false;
166161
const chat = state.chats.find((x) => x.id == action.payload.chatId);
167162
if (chat != null) {
168-
setMessagesForChat(chat, state.activeChatId, action.payload.messages);
163+
setMessagesForChat(chat, action.payload.messages);
169164
}
170165
}
171166
);

0 commit comments

Comments
 (0)