mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-24 10:37:16 +00:00
34 lines
816 B
TypeScript
34 lines
816 B
TypeScript
import WebampLazy from "../../js/webampLazy";
|
|
import React, { useEffect, useState } from "react";
|
|
// @ts-ignore
|
|
import iconLarge from "../images/manifest/icon-96x96.png";
|
|
// @ts-ignore
|
|
import iconSmall from "../images/manifest/icon-48x48.png";
|
|
import DesktopIcon from "./DesktopIcon";
|
|
|
|
const iconUrl = window.devicePixelRatio > 1 ? iconLarge : iconSmall;
|
|
|
|
interface Props {
|
|
webamp: WebampLazy;
|
|
}
|
|
|
|
const WebampIcon = (props: Props) => {
|
|
const [hidden, setHidden] = useState(true);
|
|
useEffect(() => {
|
|
return props.webamp.onClose(() => {
|
|
setHidden(false);
|
|
});
|
|
}, [props.webamp]);
|
|
|
|
if (hidden) {
|
|
return null;
|
|
}
|
|
|
|
function onOpen() {
|
|
props.webamp.reopen();
|
|
setHidden(true);
|
|
}
|
|
return <DesktopIcon iconUrl={iconUrl} name="Webamp" onOpen={onOpen} />;
|
|
};
|
|
|
|
export default WebampIcon;
|