Updated dynamic viewport title and icon
This commit is contained in:
parent
a57e680024
commit
01c5d0be93
2 changed files with 26 additions and 6 deletions
|
|
@ -86,11 +86,20 @@ export const WindowView = memo(({ id, app, size, position, onInteract, options,
|
|||
}, [position, size, screenHeight, screenWidth]);
|
||||
|
||||
useEffect(() => {
|
||||
if (active) {
|
||||
const setViewportTitleAndIcon = () => {
|
||||
setViewportTitle(`${title} | ${NAME}`);
|
||||
setViewportIcon(iconUrl);
|
||||
}
|
||||
}, [active, iconUrl, title]);
|
||||
};
|
||||
|
||||
if (active && !minimized)
|
||||
setViewportTitleAndIcon();
|
||||
|
||||
window.addEventListener("focus", setViewportTitleAndIcon);
|
||||
|
||||
return () => {
|
||||
window.removeEventListener("focus", setViewportTitleAndIcon);
|
||||
};
|
||||
}, [active, minimized, iconUrl, title]);
|
||||
|
||||
const close = (event) => {
|
||||
event?.preventDefault();
|
||||
|
|
|
|||
|
|
@ -18,12 +18,23 @@ export const WindowsView = memo(() => {
|
|||
setSortedWindows([...windows].sort((windowA, windowB) =>
|
||||
windowA.lastInteraction - windowB.lastInteraction
|
||||
));
|
||||
}, [windows]);
|
||||
|
||||
if (windows.length === 0) {
|
||||
useEffect(() => {
|
||||
const resetViewportTitleAndIcon = () => {
|
||||
setViewportTitle(`${NAME} | ${TAG_LINE}`);
|
||||
setViewportIcon(`${process.env.PUBLIC_URL}/favicon.ico`);
|
||||
}
|
||||
}, [windows]);
|
||||
};
|
||||
|
||||
if (sortedWindows.length === 0 || sortedWindows[sortedWindows.length - 1].minimized)
|
||||
resetViewportTitleAndIcon();
|
||||
|
||||
window.addEventListener("blur", resetViewportTitleAndIcon);
|
||||
|
||||
return () => {
|
||||
window.removeEventListener("blur", resetViewportTitleAndIcon);
|
||||
};
|
||||
}, [sortedWindows]);
|
||||
|
||||
// Launch startup apps
|
||||
useEffect(() => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue