From 8ea4251bcf0ae5d55f5fde191dbe7783e804058a Mon Sep 17 00:00:00 2001 From: yassinedorbozgithub Date: Thu, 30 Jan 2025 10:47:37 +0100 Subject: [PATCH] fix: remove IBroadcastChannelContext export --- .../contexts/broadcast-channel.context.tsx | 2 +- .../src/hooks/useSubscribeBroadcastChannel.ts | 20 ++++++++--------- .../src/hooks/useSubscribeBroadcastChannel.ts | 22 +++++++++---------- .../providers/BroadcastChannelProvider.tsx | 2 +- 4 files changed, 21 insertions(+), 25 deletions(-) diff --git a/frontend/src/contexts/broadcast-channel.context.tsx b/frontend/src/contexts/broadcast-channel.context.tsx index 5dd4cb22..2879089a 100644 --- a/frontend/src/contexts/broadcast-channel.context.tsx +++ b/frontend/src/contexts/broadcast-channel.context.tsx @@ -49,7 +49,7 @@ const getOrCreateTabId = () => { return storedTabId; }; -export interface IBroadcastChannelContext { +interface IBroadcastChannelContext { subscribe: ( event: `${EBCEvent}`, callback: (message: BroadcastChannelData) => void, diff --git a/frontend/src/hooks/useSubscribeBroadcastChannel.ts b/frontend/src/hooks/useSubscribeBroadcastChannel.ts index d8c4eaa9..cb43d5a2 100644 --- a/frontend/src/hooks/useSubscribeBroadcastChannel.ts +++ b/frontend/src/hooks/useSubscribeBroadcastChannel.ts @@ -8,16 +8,14 @@ import { useEffect } from "react"; -import { - IBroadcastChannelContext, - useBroadcastChannel, -} from "@/contexts/broadcast-channel.context"; +import { useBroadcastChannel } from "@/contexts/broadcast-channel.context"; -export const useSubscribeBroadcastChannel: IBroadcastChannelContext["subscribe"] = - (...props) => { - const { subscribe } = useBroadcastChannel(); +export const useSubscribeBroadcastChannel: ReturnType< + typeof useBroadcastChannel +>["subscribe"] = (...props) => { + const { subscribe } = useBroadcastChannel(); - useEffect(() => { - subscribe(...props); - }, [subscribe, ...props]); - }; + useEffect(() => { + subscribe(...props); + }, [subscribe, ...props]); +}; diff --git a/widget/src/hooks/useSubscribeBroadcastChannel.ts b/widget/src/hooks/useSubscribeBroadcastChannel.ts index fd48c071..5193b09b 100644 --- a/widget/src/hooks/useSubscribeBroadcastChannel.ts +++ b/widget/src/hooks/useSubscribeBroadcastChannel.ts @@ -8,17 +8,15 @@ import { useEffect } from "react"; -import { - IBroadcastChannelContext, - useBroadcastChannel, -} from "../providers/BroadcastChannelProvider"; +import { useBroadcastChannel } from "../providers/BroadcastChannelProvider"; -export const useSubscribeBroadcastChannel: IBroadcastChannelContext["subscribe"] = - (...props) => { - const { subscribe } = useBroadcastChannel(); +export const useSubscribeBroadcastChannel: ReturnType< + typeof useBroadcastChannel +>["subscribe"] = (...props) => { + const { subscribe } = useBroadcastChannel(); - useEffect(() => { - subscribe(...props); - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [subscribe, ...props]); - }; + useEffect(() => { + subscribe(...props); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [subscribe, ...props]); +}; diff --git a/widget/src/providers/BroadcastChannelProvider.tsx b/widget/src/providers/BroadcastChannelProvider.tsx index 7114127d..7e4a7257 100644 --- a/widget/src/providers/BroadcastChannelProvider.tsx +++ b/widget/src/providers/BroadcastChannelProvider.tsx @@ -49,7 +49,7 @@ const getOrCreateTabId = () => { return storedTabId; }; -export interface IBroadcastChannelContext { +interface IBroadcastChannelContext { subscribe: ( event: `${EBCEvent}`, callback: (message: BroadcastChannelData) => void,