From 4d1ef66986e4201552a4e5196141cb3d125b6c66 Mon Sep 17 00:00:00 2001
From: m5r <mokht@rmi.al>
Date: Sat, 18 Sep 2021 05:35:51 +0800
Subject: [PATCH] memoize isServiceWorkerSupported in useNotifications hook

---
 app/core/hooks/use-notifications.ts | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/app/core/hooks/use-notifications.ts b/app/core/hooks/use-notifications.ts
index a676dd3..228fd4b 100644
--- a/app/core/hooks/use-notifications.ts
+++ b/app/core/hooks/use-notifications.ts
@@ -1,5 +1,5 @@
 import { getConfig, useMutation } from "blitz";
-import { useEffect, useState } from "react";
+import { useEffect, useMemo, useState } from "react";
 
 import setNotificationSubscription from "../mutations/set-notification-subscription";
 import useCurrentPhoneNumber from "./use-current-phone-number";
@@ -7,7 +7,7 @@ import useCurrentPhoneNumber from "./use-current-phone-number";
 const { publicRuntimeConfig } = getConfig();
 
 export default function useNotifications() {
-	const isServiceWorkerSupported = "serviceWorker" in navigator;
+	const isServiceWorkerSupported = useMemo(() => "serviceWorker" in navigator, []);
 	const [subscription, setSubscription] = useState<PushSubscription | null>(null);
 	const [setNotificationSubscriptionMutation] = useMutation(setNotificationSubscription);
 	const phoneNumber = useCurrentPhoneNumber();