diff --git a/src/components/room/widgets/RoomWidgetsView.tsx b/src/components/room/widgets/RoomWidgetsView.tsx index 7768aa5..66745c2 100644 --- a/src/components/room/widgets/RoomWidgetsView.tsx +++ b/src/components/room/widgets/RoomWidgetsView.tsx @@ -2,7 +2,7 @@ import { GetRoomEngine, RoomEngineObjectEvent, RoomEngineRoomAdEvent, RoomEngine import { FC } from 'react'; import { DispatchUiEvent, LocalizeText, NotificationAlertType, RoomWidgetUpdateRoomObjectEvent } from '../../../api'; import { WidgetErrorBoundary } from '../../../common'; -import { useNitroEvent, useNotification, useRoom } from '../../../hooks'; +import { useNitroEvent, useNotification, usePollSubscriptions, useRoom } from '../../../hooks'; import { AvatarInfoWidgetView } from './avatar-info/AvatarInfoWidgetView'; import { ChatInputView } from './chat-input/ChatInputView'; import { ChatWidgetView } from './chat/ChatWidgetView'; @@ -22,6 +22,11 @@ export const RoomWidgetsView: FC<{}> = props => const { roomSession = null } = useRoom(); const { simpleAlert = null } = useNotification(); + // Bridge RoomSessionPollEvent (OFFER/ERROR/CONTENT) onto the UI bus + // for the lifetime of the room session. Single mount point so the + // listeners are not re-registered per widget render. + usePollSubscriptions(); + useNitroEvent(RoomZoomEvent.ROOM_ZOOM, event => GetRoomEngine().setRoomInstanceRenderingCanvasScale(event.roomId, 1, (((event.level)<1) ? 0.5 : (1 << (Math.floor(event.level) - 1))), null, null, event.isFlipForced)); useNitroEvent( diff --git a/src/hooks/rooms/widgets/usePollWidget.ts b/src/hooks/rooms/widgets/usePollWidget.ts index 746ae99..ce1e505 100644 --- a/src/hooks/rooms/widgets/usePollWidget.ts +++ b/src/hooks/rooms/widgets/usePollWidget.ts @@ -1,17 +1,12 @@ import { usePollActions } from './usePollActions'; -import { usePollSubscriptions } from './usePollSubscriptions'; /** - * @deprecated Prefer `usePollSubscriptions` (mount once, top-level) and - * `usePollActions` (anywhere a component dispatches a vote/accept/reject). - * This shim preserves the old `{ startPoll, rejectPoll, answerPoll }` - * shape for existing consumers, but each call also re-mounts the three - * subscription listeners — which is wrong if the hook is called from - * multiple places. + * @deprecated Prefer `usePollActions` for components that dispatch + * votes/accepts/rejects. The corresponding subscriptions are now mounted + * once by `RoomWidgetsView` via `usePollSubscriptions`, so this shim no + * longer needs to register them transitively. + * + * Kept only to preserve the `{ startPoll, rejectPoll, answerPoll }` + * shape for any out-of-tree consumer; remove once nothing imports it. */ -export const usePollWidget = () => -{ - usePollSubscriptions(); - - return usePollActions(); -}; +export const usePollWidget = () => usePollActions();