diff --git a/app/src/app/app/layout.tsx b/app/src/app/app/layout.tsx index fae5d990..971b5f05 100644 --- a/app/src/app/app/layout.tsx +++ b/app/src/app/app/layout.tsx @@ -22,7 +22,10 @@ export default async function AppLayout({ children }: Readonly) { - +
diff --git a/app/src/pusher/components/BeamsContext.tsx b/app/src/pusher/components/BeamsContext.tsx index 97249076..1e2cf887 100644 --- a/app/src/pusher/components/BeamsContext.tsx +++ b/app/src/pusher/components/BeamsContext.tsx @@ -1,5 +1,6 @@ "use client"; +import type { User } from "@prisma/client"; import dynamic from "next/dynamic"; import type { Dispatch, ReactNode, SetStateAction } from "react"; import { createContext, useContext, useEffect, useMemo, useState } from "react"; @@ -18,9 +19,10 @@ const BeamsContext = createContext(undefined); type Props = Readonly<{ children: ReactNode; instanceId?: string; + userId: User["id"]; }>; -export const BeamsProvider = ({ children, instanceId }: Props) => { +export const BeamsProvider = ({ children, instanceId, userId }: Props) => { const [interests, setInterests] = useState(undefined); useEffect(() => { @@ -49,7 +51,7 @@ export const BeamsProvider = ({ children, instanceId }: Props) => { return ( {children} - {instanceId && } + {instanceId && } ); }; diff --git a/app/src/pusher/components/Client.tsx b/app/src/pusher/components/Client.tsx index a49502d7..b65918ac 100644 --- a/app/src/pusher/components/Client.tsx +++ b/app/src/pusher/components/Client.tsx @@ -1,5 +1,6 @@ "use client"; +import type { User } from "@prisma/client"; import * as PusherPushNotifications from "@pusher/push-notifications-web"; import { useEffect } from "react"; import toast from "react-hot-toast"; @@ -7,9 +8,10 @@ import { useBeamsContext } from "./BeamsContext"; type Props = Readonly<{ instanceId: string; + userId: User["id"]; }>; -export const Client = ({ instanceId }: Props) => { +export const Client = ({ instanceId, userId }: Props) => { const { interests } = useBeamsContext(); useEffect(() => { @@ -24,24 +26,28 @@ export const Client = ({ instanceId }: Props) => { if (interests.length <= 0) { void beamsClient.stop(); - console.info("[Pusher] Client stopped"); + console.info("[Pusher] Client stopped."); return; } void beamsClient .start() .then(() => { - console.info("[Pusher] Client started"); - return beamsClient.setDeviceInterests(interests); + const _interests = [...interests, `debug-user-${userId}`]; + console.info( + "[Pusher] Client started. Settings interests...", + _interests, + ); + return beamsClient.setDeviceInterests(_interests); }) .then(() => { - console.info("[Pusher] Device interests set"); + console.info("[Pusher] Device interests set."); }); } catch (error) { - console.error("[Pusher] Error initializing client", error); + console.error("[Pusher] Error initializing client.", error); toast.error("Benachrichtigungen konnten nicht aktiviert werden."); } - }, [interests, instanceId]); + }, [interests, instanceId, userId]); return null; };