Move update indicator to titlebar on desktop.

This commit is contained in:
Paul
2021-08-01 17:52:44 +01:00
parent 6baaccd70d
commit 796dc467b8
6 changed files with 32 additions and 27 deletions

View File

@@ -1,4 +1,5 @@
import { Download } from "@styled-icons/boxicons-regular";
import { CloudDownload } from "@styled-icons/boxicons-regular";
import { useContext, useEffect, useState } from "preact/hooks";
@@ -13,7 +14,11 @@ import { updateSW } from "../../main";
let pendingUpdate = false;
internalSubscribe("PWA", "update", () => (pendingUpdate = true));
export default function UpdateIndicator() {
interface Props {
style: "titlebar" | "channel";
}
export default function UpdateIndicator({ style }: Props) {
const [pending, setPending] = useState(pendingUpdate);
useEffect(() => {
@@ -23,6 +28,16 @@ export default function UpdateIndicator() {
if (!pending) return null;
const theme = useContext(ThemeContext);
if (style === "titlebar") {
return (
<div onClick={() => updateSW(true)}>
<CloudDownload size={22} color={theme.success} />
</div>
);
}
if (window.isNative) return null;
return (
<IconButton onClick={() => updateSW(true)}>
<Download size={22} color={theme.success} />