From 977b0903fac962f6ae7a3ced4dc1f3b13526e50f Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Wed, 28 Jul 2021 21:44:49 +0300 Subject: [PATCH] Workaround for infinite increment of Dev Tools DOM Nodes counter --- src/components/main/Main.tsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/components/main/Main.tsx b/src/components/main/Main.tsx index 8c18266cf..c6bee19aa 100644 --- a/src/components/main/Main.tsx +++ b/src/components/main/Main.tsx @@ -153,11 +153,11 @@ const Main: FC = ({ if (index % 2 === 0) { const newUnread = selectCountNotMutedUnread(getGlobal()) - initialUnread; if (newUnread > 0) { - document.title = `${newUnread} notification${newUnread > 1 ? 's' : ''}`; + updatePageTitle(`${newUnread} notification${newUnread > 1 ? 's' : ''}`); updateIcon(true); } } else { - document.title = PAGE_TITLE; + updatePageTitle(PAGE_TITLE); updateIcon(false); } @@ -172,7 +172,7 @@ const Main: FC = ({ notificationInterval = undefined; if (!document.title.includes(INACTIVE_MARKER)) { - document.title = PAGE_TITLE; + updatePageTitle(PAGE_TITLE); } updateIcon(false); @@ -216,6 +216,14 @@ function updateIcon(asUnread: boolean) { }); } +// For some reason setting `document.title` to the same value +// causes increment of Chrome Dev Tools > Performance Monitor > DOM Nodes counter +function updatePageTitle(nextTitle: string) { + if (document.title !== nextTitle) { + document.title = nextTitle; + } +} + export default memo(withGlobal( (global): StateProps => { const { chatId: audioChatId, messageId: audioMessageId } = global.audioPlayer;