mirror of
https://github.com/revoltchat/revite.git
synced 2024-11-14 11:15:02 -05:00
26 lines
845 B
TypeScript
26 lines
845 B
TypeScript
import { updateSW } from "../../main";
|
|
import IconButton from "../ui/IconButton";
|
|
import { ThemeContext } from "../../context/Theme";
|
|
import { Download } from "@styled-icons/boxicons-regular";
|
|
import { internalSubscribe } from "../../lib/eventEmitter";
|
|
import { useContext, useEffect, useState } from "preact/hooks";
|
|
|
|
var pendingUpdate = false;
|
|
internalSubscribe('PWA', 'update', () => pendingUpdate = true);
|
|
|
|
export default function UpdateIndicator() {
|
|
const [ pending, setPending ] = useState(pendingUpdate);
|
|
|
|
useEffect(() => {
|
|
return internalSubscribe('PWA', 'update', () => setPending(true));
|
|
});
|
|
|
|
if (!pending) return;
|
|
const theme = useContext(ThemeContext);
|
|
|
|
return (
|
|
<IconButton onClick={() => updateSW(true)}>
|
|
<Download size={22} color={theme.success} />
|
|
</IconButton>
|
|
)
|
|
}
|