TelegramPWA/src/util/updatePageTitle.ts
Alexander Zinchuk 3cd9192c1d Electron: Load application from URL (#3774)
Electron: safe fallback for missed background image in cache (#3883)
2023-09-25 14:41:13 +02:00

22 lines
651 B
TypeScript

import { debounce } from './schedulers';
import { IS_ELECTRON } from './windowEnvironment';
const UPDATE_DEBOUNCE_MS = 200;
// For some reason setting `document.title` to the same value
// causes increment of Chrome Dev Tools > Performance Monitor > DOM Nodes counter
export function setPageTitleInstant(nextTitle: string) {
if (IS_ELECTRON) {
window.electron!.setWindowTitle(nextTitle);
return;
}
if (document.title !== nextTitle) {
document.title = nextTitle;
}
}
// Synchronous page title update has conflicts with History API in Chrome
export const setPageTitle = debounce(setPageTitleInstant, UPDATE_DEBOUNCE_MS, false);