Fix refreshing things when permission is granted

We refreshed some things but not everything, this makes it more
responsive if you have the settings page open when granting permissions,
for example.
This commit is contained in:
nimbleghost
2023-06-28 20:26:54 +02:00
parent 64ac111d55
commit 9ce3545901
4 changed files with 39 additions and 38 deletions

View File

@@ -49,7 +49,7 @@ import { ReserveAddDialog, ReserveDeleteDialog, ReserveEditDialog } from "./Rese
import { UnauthorizedError } from "../app/errors";
import { subscribeTopic } from "./SubscribeDialog";
import notifier from "../app/Notifier";
import { useIsLaunchedPWA } from "./hooks";
import { useIsLaunchedPWA, useNotificationPermissionListener } from "./hooks";
const maybeUpdateAccountSettings = async (payload) => {
if (!session.exists()) {
@@ -79,6 +79,7 @@ const Preferences = () => (
const Notifications = () => {
const { t } = useTranslation();
const isLaunchedPWA = useIsLaunchedPWA();
const pushPossible = useNotificationPermissionListener(() => notifier.pushPossible());
return (
<Card sx={{ p: 3 }} aria-label={t("prefs_notifications_title")}>
@@ -89,7 +90,7 @@ const Notifications = () => {
<Sound />
<MinPriority />
<DeleteAfter />
{!isLaunchedPWA && notifier.pushPossible() && <WebPushEnabled />}
{!isLaunchedPWA && pushPossible && <WebPushEnabled />}
</PrefGroup>
</Card>
);