fix(pwa): tighten install support detection
This commit is contained in:
@@ -43,22 +43,27 @@ export function SidebarScreen() {
|
||||
]);
|
||||
|
||||
useEffect(() => {
|
||||
const updateInstallEntryVisibility = () => {
|
||||
setCanShowInstallApp(pwaUtil.canShowInstallEntry());
|
||||
};
|
||||
|
||||
pwaUtil.prepareInstallPrompt();
|
||||
const timer = window.setTimeout(() => {
|
||||
setCanShowInstallApp(pwaUtil.isSupported() && !pwaUtil.isInstalled());
|
||||
}, 0);
|
||||
updateInstallEntryVisibility();
|
||||
const unsubscribe = pwaUtil.subscribe(updateInstallEntryVisibility);
|
||||
|
||||
return () => {
|
||||
window.clearTimeout(timer);
|
||||
unsubscribe();
|
||||
};
|
||||
}, []);
|
||||
|
||||
const handleInstallAppClick = async () => {
|
||||
pwaUtil.prepareInstallPrompt();
|
||||
const result = await pwaUtil.install();
|
||||
if (result === "accepted" || pwaUtil.isInstalled()) {
|
||||
setCanShowInstallApp(false);
|
||||
}
|
||||
setCanShowInstallApp(
|
||||
result !== "accepted" &&
|
||||
!pwaUtil.isInstalled() &&
|
||||
pwaUtil.canShowInstallEntry(),
|
||||
);
|
||||
};
|
||||
|
||||
const handleLogoutClick = () => {
|
||||
|
||||
Reference in New Issue
Block a user