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;