From e752934fd5c3e93a078f3b828b97e4145c2e6530 Mon Sep 17 00:00:00 2001 From: janWilejan <119548498+janWilejan@users.noreply.github.com> Date: Sat, 24 Jun 2023 02:12:34 +0000 Subject: [PATCH] fix TitleNotifier crash (#3100) rare chance of crashing when using ReactRefresh with an empty chat Co-authored-by: janWilejan <> --- web/components/TitleNotifier/TitleNotifier.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/components/TitleNotifier/TitleNotifier.tsx b/web/components/TitleNotifier/TitleNotifier.tsx index dfffcc5b8..a6f3dce62 100644 --- a/web/components/TitleNotifier/TitleNotifier.tsx +++ b/web/components/TitleNotifier/TitleNotifier.tsx @@ -58,8 +58,8 @@ export const TitleNotifier: FC = ({ name }) => { } // Only alert on real chat messages from people. - const lastMessage = chatMessages[chatMessages.length - 1]; - if (lastMessage.type !== 'CHAT') { + const lastMessage = chatMessages.at(-1); + if (!lastMessage || lastMessage.type !== 'CHAT') { return; }