From 353e9c5896b3d138f89b8edb0dd7f6d756770064 Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Sat, 24 Dec 2022 21:21:39 -0800 Subject: [PATCH] Add logging to troubleshoot #2351 --- web/components/TitleNotifier/TitleNotifier.tsx | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/web/components/TitleNotifier/TitleNotifier.tsx b/web/components/TitleNotifier/TitleNotifier.tsx index 6e90d2e72..4ff3a3d0b 100644 --- a/web/components/TitleNotifier/TitleNotifier.tsx +++ b/web/components/TitleNotifier/TitleNotifier.tsx @@ -16,14 +16,20 @@ export const TitleNotifier: FC = () => { let backgrounded = false; let defaultTitle = ''; + const setTitle = (title: string) => { + console.trace('Debug: Setting title to', title); + window.document.title = title; + }; + const onBlur = () => { + console.log('onBlur: Saving defaultTitle as', window.document.title); backgrounded = true; defaultTitle = window.document.title; }; const onFocus = () => { backgrounded = false; - window.document.title = defaultTitle; + setTitle(defaultTitle); }; const listenForEvents = () => { @@ -33,6 +39,8 @@ export const TitleNotifier: FC = () => { }; useEffect(() => { + console.log('useEffect: Saving defaultTitle as', window.document.title); + defaultTitle = window.document.title; listenForEvents(); @@ -48,8 +56,7 @@ export const TitleNotifier: FC = () => { if (!backgrounded || !online) { return; } - - window.document.title = `💬 :: ${defaultTitle}`; + setTitle(`💬 :: ${defaultTitle}`); }, [chatMessages]); useEffect(() => { @@ -60,9 +67,9 @@ export const TitleNotifier: FC = () => { const { online } = serverStatus; if (online) { - window.document.title = ` 🟢 :: ${defaultTitle}`; + setTitle(` 🟢 :: ${defaultTitle}`); } else if (!online) { - window.document.title = ` 🔴 :: ${defaultTitle}`; + setTitle(` 🔴 :: ${defaultTitle}`); } }, [serverStatusState]);