mirror of
https://github.com/open-webui/open-webui.git
synced 2026-08-28 05:27:35 +00:00
fix: add null guards to channel Thread and PinnedMessagesModal components (#25209)
Thread.svelte: Add null check for messagesContainerElement in scrollToBottom() to match the existing pattern in Channel.svelte. Prevents potential TypeError when the DOM element is not yet bound during rapid thread switches. PinnedMessagesModal.svelte: Move res.length check inside the if (res) block. Previously, res.length was accessed unconditionally after a guarded block, causing TypeError when the API call fails and the .catch() returns null.
This commit is contained in:
parent
f16b5c4460
commit
5112e0b62c
2 changed files with 6 additions and 4 deletions
|
|
@ -37,10 +37,10 @@
|
|||
|
||||
if (res) {
|
||||
pinnedMessages = [...(pinnedMessages ?? []), ...res];
|
||||
}
|
||||
|
||||
if (res.length === 0) {
|
||||
allItemsLoaded = true;
|
||||
if (res.length === 0) {
|
||||
allItemsLoaded = true;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error fetching pinned messages:', error);
|
||||
|
|
|
|||
|
|
@ -35,7 +35,9 @@
|
|||
}
|
||||
|
||||
const scrollToBottom = () => {
|
||||
messagesContainerElement.scrollTop = messagesContainerElement.scrollHeight;
|
||||
if (messagesContainerElement) {
|
||||
messagesContainerElement.scrollTop = messagesContainerElement.scrollHeight;
|
||||
}
|
||||
};
|
||||
|
||||
const initHandler = async () => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue