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]);
|
}, [position, size, screenHeight, screenWidth]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (active) {
|
const setViewportTitleAndIcon = () => {
|
||||||
setViewportTitle(`${title} | ${NAME}`);
|
setViewportTitle(`${title} | ${NAME}`);
|
||||||
setViewportIcon(iconUrl);
|
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) => {
|
const close = (event) => {
|
||||||
event?.preventDefault();
|
event?.preventDefault();
|
||||||
|
|
|
||||||
|
|
@ -18,12 +18,23 @@ export const WindowsView = memo(() => {
|
||||||
setSortedWindows([...windows].sort((windowA, windowB) =>
|
setSortedWindows([...windows].sort((windowA, windowB) =>
|
||||||
windowA.lastInteraction - windowB.lastInteraction
|
windowA.lastInteraction - windowB.lastInteraction
|
||||||
));
|
));
|
||||||
|
}, [windows]);
|
||||||
|
|
||||||
if (windows.length === 0) {
|
useEffect(() => {
|
||||||
|
const resetViewportTitleAndIcon = () => {
|
||||||
setViewportTitle(`${NAME} | ${TAG_LINE}`);
|
setViewportTitle(`${NAME} | ${TAG_LINE}`);
|
||||||
setViewportIcon(`${process.env.PUBLIC_URL}/favicon.ico`);
|
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
|
// Launch startup apps
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue