fix: refreshing a new chat with Landing Page Mode set to Chat no longer throws a TypeError (#32510)

With Settings > Interface > Landing Page Mode set to Chat, the new chat
page renders the message list, so the block that reveals a message picked
from search ran there too. With no chat open, chat?.id and
$page.params.id are both undefined, the guard passed, and chat.id threw
"can't access property 'id'" on every refresh.

Require a chat before comparing its id with the page's.
This commit is contained in:
G30 2026-10-15 19:48:05 -04:00 • committed by GitHub
parent a575875cc3
commit 5d4f16bcc9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1225,7 +1225,7 @@
};
let revealedSearchMessage = '';
$: if (!embedded && !loading && messagesRef && chat?.id === $page.params.id) {
$: if (!embedded && !loading && messagesRef && chat && chat.id === $page.params.id) {
const target = $page.url.searchParams.get('message');
const key = `${chat.id}:${target}`;
if (target && history.messages[target] && key !== revealedSearchMessage) {