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:
G30 2026-05-31 18:01:17 -04:00 committed by GitHub
parent f16b5c4460
commit 5112e0b62c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 4 deletions

View file

@ -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);

View file

@ -35,7 +35,9 @@
}
const scrollToBottom = () => {
messagesContainerElement.scrollTop = messagesContainerElement.scrollHeight;
if (messagesContainerElement) {
messagesContainerElement.scrollTop = messagesContainerElement.scrollHeight;
}
};
const initHandler = async () => {