mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-29 19:35:20 +02:00
fix: update message handling in NewChatPage to conditionally set author_id based on chat visibility
This commit is contained in:
parent
05030f6664
commit
7ed6e9c75f
1 changed files with 5 additions and 3 deletions
|
|
@ -218,13 +218,15 @@ export default function NewChatPage() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isSharedChat = currentThread?.visibility === "SEARCH_SPACE";
|
||||||
|
|
||||||
setMessages((prev) => {
|
setMessages((prev) => {
|
||||||
if (syncedMessages.length < prev.length) {
|
if (syncedMessages.length < prev.length) {
|
||||||
return prev;
|
return prev;
|
||||||
}
|
}
|
||||||
|
|
||||||
return syncedMessages.map((msg) => {
|
return syncedMessages.map((msg) => {
|
||||||
const member = msg.author_id
|
const member = isSharedChat && msg.author_id
|
||||||
? membersData?.find((m) => m.user_id === msg.author_id)
|
? membersData?.find((m) => m.user_id === msg.author_id)
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
|
|
@ -239,7 +241,7 @@ export default function NewChatPage() {
|
||||||
thread_id: msg.thread_id,
|
thread_id: msg.thread_id,
|
||||||
role: msg.role.toLowerCase() as "user" | "assistant" | "system",
|
role: msg.role.toLowerCase() as "user" | "assistant" | "system",
|
||||||
content: msg.content,
|
content: msg.content,
|
||||||
author_id: msg.author_id,
|
author_id: isSharedChat ? msg.author_id : null,
|
||||||
created_at: msg.created_at,
|
created_at: msg.created_at,
|
||||||
author_display_name: member?.user_display_name ?? existingAuthor?.displayName ?? null,
|
author_display_name: member?.user_display_name ?? existingAuthor?.displayName ?? null,
|
||||||
author_avatar_url: member?.user_avatar_url ?? existingAuthor?.avatarUrl ?? null,
|
author_avatar_url: member?.user_avatar_url ?? existingAuthor?.avatarUrl ?? null,
|
||||||
|
|
@ -247,7 +249,7 @@ export default function NewChatPage() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
[isRunning, membersData]
|
[isRunning, membersData, currentThread?.visibility]
|
||||||
);
|
);
|
||||||
|
|
||||||
useMessagesSync(threadId, handleSyncedMessagesUpdate);
|
useMessagesSync(threadId, handleSyncedMessagesUpdate);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue