Workaround for infinite increment of Dev Tools DOM Nodes counter

This commit is contained in:
Alexander Zinchuk 2021-07-28 21:44:49 +03:00
parent 6ce9ee58ae
commit 977b0903fa

View File

@ -153,11 +153,11 @@ const Main: FC<StateProps & DispatchProps> = ({
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<StateProps & DispatchProps> = ({
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;