mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-12 20:35:19 +00:00
fix: correct chat preview loading in search modal
This commit fixes a bug in the search modal where the chat preview would fail to load for the bottom search results, especially when using tags to filter. The issue was caused by an incorrect index calculation in the `loadChatPreview` function, which resulted in an out-of-bounds error when accessing the `chatList` array. This commit resolves the issue by adding a guard clause to the `loadChatPreview` function to ensure that the `selectedChatIdx` is always a valid index. This prevents the out-of-bounds error and ensures that the chat preview is always displayed for the selected chat.
This commit is contained in:
parent
08bc00ea77
commit
71b86c08ee
1 changed files with 5 additions and 7 deletions
|
|
@ -56,12 +56,7 @@
|
|||
}
|
||||
|
||||
const loadChatPreview = async (selectedIdx) => {
|
||||
if (
|
||||
!chatList ||
|
||||
chatList.length === 0 ||
|
||||
selectedIdx === null ||
|
||||
chatList[selectedIdx] === undefined
|
||||
) {
|
||||
if (!chatList || chatList.length === 0 || selectedIdx === null) {
|
||||
selectedChat = null;
|
||||
messages = null;
|
||||
history = null;
|
||||
|
|
@ -70,8 +65,11 @@
|
|||
}
|
||||
|
||||
const selectedChatIdx = selectedIdx - actions.length;
|
||||
if (selectedChatIdx < 0) {
|
||||
if (selectedChatIdx < 0 || selectedChatIdx >= chatList.length) {
|
||||
selectedChat = null;
|
||||
messages = null;
|
||||
history = null;
|
||||
selectedModels = [''];
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue