Skip to content

Commit a54f88e

Browse files
authored
πŸ› Keep the likes and dislikes after switching conversations #806
2 parents 7f64059 + baa444e commit a54f88e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

β€Žfrontend/app/[locale]/chat/internal/chatInterface.tsxβ€Ž

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,6 +1262,20 @@ export function ChatInterface() {
12621262
await conversationService.updateOpinion({ message_id: messageId, opinion });
12631263
setSessionMessages((prev) => {
12641264
const newMessages = { ...prev };
1265+
// Update the opinion_flag for the specific message in all conversations
1266+
Object.keys(newMessages).forEach(conversationId => {
1267+
const messages = newMessages[parseInt(conversationId)];
1268+
if (messages) {
1269+
const messageIndex = messages.findIndex(msg => msg.message_id === messageId);
1270+
if (messageIndex !== -1) {
1271+
newMessages[parseInt(conversationId)] = [...messages];
1272+
newMessages[parseInt(conversationId)][messageIndex] = {
1273+
...newMessages[parseInt(conversationId)][messageIndex],
1274+
opinion_flag: opinion || undefined
1275+
};
1276+
}
1277+
}
1278+
});
12651279
return newMessages;
12661280
});
12671281
} catch (error) {

0 commit comments

Comments
Β (0)