diff --git a/src/app/config.ts b/src/app/config.ts index 6bdbc676..ad2de93a 100644 --- a/src/app/config.ts +++ b/src/app/config.ts @@ -25,7 +25,7 @@ export const ChatPrefixes = { channel: "#", user: "@" }; -export const vapidKey = `BGXCn-5YRXSFw38Q9lUKJ5bibL212-yIQn1pCvthGhp6_KwA29FO1Ax_d_7if1vfC2a5wTSVO8AcZrc-Hm1aS0Y`; +export const vapidKey = `BOmzyZhw-DcIGYQ77mzQUVqLlcvn0bm_76P_kc7rpwRxzXNbui-JP8iPyEQYfyoxyJeq43Ud4IiIsJSMNHNujn0`; export const tokenHeader = "X-API-Key"; export const FILE_SLICE_SIZE = 1000 * 200 * 8; //200kb export const FILE_IMAGE_SIZE = 1000 * 10000 * 8; //10mb diff --git a/src/common/component/Notification/index.tsx b/src/common/component/Notification/index.tsx index 93d109e1..43831568 100644 --- a/src/common/component/Notification/index.tsx +++ b/src/common/component/Notification/index.tsx @@ -1,18 +1,21 @@ -import { useEffect } from "react"; +import { useEffect, memo } from "react"; import { useNavigate } from "react-router-dom"; import useDeviceToken from "./useDeviceToken"; import { vapidKey } from "../../../app/config"; import { useUpdateDeviceTokenMutation } from "../../../app/services/auth"; - +let updated = false; const Notification = () => { const navigateTo = useNavigate(); const token = useDeviceToken(vapidKey); - const [updateDeviceToken] = useUpdateDeviceTokenMutation(); + const [updateDeviceToken, { isSuccess }] = useUpdateDeviceTokenMutation(); useEffect(() => { - if (token) { + if (token && !updated) { updateDeviceToken(token); } }, [token]); + useEffect(() => { + updated = isSuccess; + }, [isSuccess]); useEffect(() => { const handleServiceworkerMessage = (event: MessageEvent) => { @@ -29,4 +32,4 @@ const Notification = () => { return null; }; -export default Notification; +export default memo(Notification);