From 228d787bf9997bf20d8d9225bd8dfeb668e72973 Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Sat, 15 Apr 2023 14:22:14 -0700 Subject: [PATCH] fix(web): set document title via dom instead of javascript. Closes #2918 --- web/components/TitleNotifier/TitleNotifier.tsx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/web/components/TitleNotifier/TitleNotifier.tsx b/web/components/TitleNotifier/TitleNotifier.tsx index e095f636e..dfffcc5b8 100644 --- a/web/components/TitleNotifier/TitleNotifier.tsx +++ b/web/components/TitleNotifier/TitleNotifier.tsx @@ -7,6 +7,7 @@ */ import { FC, useEffect, useState } from 'react'; import { useRecoilValue } from 'recoil'; +import Head from 'next/head'; import { serverStatusState, chatMessagesAtom } from '../stores/ClientConfigStore'; export type TitleNotifierProps = { @@ -18,13 +19,10 @@ export const TitleNotifier: FC = ({ name }) => { const serverStatus = useRecoilValue(serverStatusState); const [backgrounded, setBackgrounded] = useState(false); + const [title, setTitle] = useState(name); const { online } = serverStatus; - const setTitle = (title: string) => { - document.title = title; - }; - const onBlur = () => { setBackgrounded(true); }; @@ -47,6 +45,7 @@ export const TitleNotifier: FC = ({ name }) => { useEffect(() => { listenForEvents(); + setTitle(name); return () => { removeEvents(); @@ -71,7 +70,6 @@ export const TitleNotifier: FC = ({ name }) => { if (!backgrounded) { return; } - if (online) { setTitle(` 🟢 :: ${name}`); } else if (!online) { @@ -79,5 +77,9 @@ export const TitleNotifier: FC = ({ name }) => { } }, [online, name]); - return null; + return ( + + {title} + + ); };