Fix: Reset all data except the first one on the chat page shared with others #3221 (#9567)

### What problem does this PR solve?

Fix: Reset all data except the first one on the chat page shared with
others #3221

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
balibabu
2025-08-19 19:04:40 +08:00
committed by GitHub
parent d0dc56166c
commit 00f54c207e
3 changed files with 14 additions and 2 deletions

View File

@ -557,6 +557,15 @@ export const useSelectDerivedMessages = () => {
setDerivedMessages([]);
}, [setDerivedMessages]);
const removeAllMessagesExceptFirst = useCallback(() => {
setDerivedMessages((list) => {
if (list.length <= 1) {
return list;
}
return list.slice(0, 1);
});
}, [setDerivedMessages]);
return {
scrollRef,
messageContainerRef,
@ -571,6 +580,7 @@ export const useSelectDerivedMessages = () => {
removeMessagesAfterCurrentMessage,
removeAllMessages,
scrollToBottom,
removeAllMessagesExceptFirst,
};
};