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 authored and GitHub committed 2026-10-16 03:48:05 +04:00
1 parent a575875cc3
commit 5d4f16bcc9
1 file changed
+1 -1
+1 -1
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) {