fix: server logo at first enter

This commit is contained in:
Tristan Yang
2022-06-28 11:59:32 +08:00
parent 7f2b39ec36
commit 84ff7a619f
2 changed files with 8 additions and 12 deletions
+4 -5
View File
@@ -1,4 +1,4 @@
import { useEffect, useState, useRef } from "react";
import { useEffect, useState, useRef, SyntheticEvent } from "react";
import Prompt from "./Prompt";
import usePrompt from "./usePrompt";
@@ -6,9 +6,8 @@ export default function Manifest() {
const { setCanceled: setCanceled, prompted } = usePrompt();
const deferredPromptRef = useRef(null);
const [popup, setPopup] = useState(false);
// const { data, isSuccess } = useGetServerQuery();
useEffect(() => {
const handleInstallPromotion = (e) => {
const handleInstallPromotion = (e: SyntheticEvent) => {
// Prevent the mini-infobar from appearing on mobile
e.preventDefault();
// Stash the event so it can be triggered later.
@@ -36,10 +35,10 @@ export default function Manifest() {
// }
// }
window.addEventListener("beforeinstallprompt", handleInstallPromotion);
window.addEventListener("beforeinstallprompt", handleInstallPromotion, true);
window.addEventListener("appinstalled", handleInstalled);
return () => {
window.removeEventListener("beforeinstallprompt", handleInstallPromotion);
window.removeEventListener("beforeinstallprompt", handleInstallPromotion, true);
window.removeEventListener("appinstalled", handleInstalled);
};
}, []);