From 1b0e84ebc0f046ca0afd69e5818b28cf5fe78643 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ram=C3=B3n=20Souza?= Date: Mon, 5 Aug 2024 14:21:23 -0300 Subject: [PATCH] fix ts errors --- .../breakout-room-user-assignment/component.tsx | 4 ++-- .../create-breakout-room/component.tsx | 11 ++++++++--- .../room-managment-state/component.tsx | 9 +++++++++ .../room-managment-state/types.ts | 17 +++++++++++++++++ 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/bigbluebutton-html5/imports/ui/components/breakout-room/create-breakout-room/breakout-room-user-assignment/component.tsx b/bigbluebutton-html5/imports/ui/components/breakout-room/create-breakout-room/breakout-room-user-assignment/component.tsx index 1513d4d0d2..26f1f76817 100644 --- a/bigbluebutton-html5/imports/ui/components/breakout-room/create-breakout-room/breakout-room-user-assignment/component.tsx +++ b/bigbluebutton-html5/imports/ui/components/breakout-room/create-breakout-room/breakout-room-user-assignment/component.tsx @@ -230,10 +230,10 @@ const BreakoutRoomUserAssignment: React.FC = ({ return Object.values(rooms).filter((r) => r.name === roomName).length > 1; }; - const changeRoomPresentation = (position) => (ev) => { + const changeRoomPresentation = (position: number) => (ev: React.ChangeEvent) => { + // @ts-ignore-next-line const newRoomsPresentations = [...roomPresentations]; newRoomsPresentations[position] = ev.target.value; - setRoomPresentations(newRoomsPresentations); }; diff --git a/bigbluebutton-html5/imports/ui/components/breakout-room/create-breakout-room/component.tsx b/bigbluebutton-html5/imports/ui/components/breakout-room/create-breakout-room/component.tsx index 9e5b394baa..6870449841 100644 --- a/bigbluebutton-html5/imports/ui/components/breakout-room/create-breakout-room/component.tsx +++ b/bigbluebutton-html5/imports/ui/components/breakout-room/create-breakout-room/component.tsx @@ -24,6 +24,8 @@ import { RoomToWithSettings, BreakoutUser, moveUserRegistery, + Presentation, + RoomPresentations, } from './room-managment-state/types'; import { BREAKOUT_ROOM_CREATE, BREAKOUT_ROOM_MOVE_USER } from '../mutations'; import useDeduplicatedSubscription from '/imports/ui/core/hooks/useDeduplicatedSubscription'; @@ -44,6 +46,8 @@ interface CreateBreakoutRoomProps extends CreateBreakoutRoomContainerProps { isBreakoutRecordable: boolean, users: Array, runningRooms: getBreakoutsResponse['breakoutRoom'], + presentations: Array, + currentPresentation: string, } const intlMessages = defineMessages({ @@ -239,7 +243,7 @@ const CreateBreakoutRoom: React.FC = ({ const [durationTime, setDurationTime] = React.useState(DEFAULT_BREAKOUT_TIME); const isImportPresentationWithAnnotationsEnabled = useIsImportPresentationWithAnnotationsFromBreakoutRoomsEnabled(); const isImportSharedNotesEnabled = useIsImportSharedNotesFromBreakoutRoomsEnabled(); - const [roomPresentations, setRoomPresentations] = React.useState([]); + const [roomPresentations, setRoomPresentations] = React.useState([]); const [createBreakoutRoom] = useMutation(BREAKOUT_ROOM_CREATE); const [moveUser] = useMutation(BREAKOUT_ROOM_MOVE_USER); @@ -261,7 +265,8 @@ const CreateBreakoutRoom: React.FC = ({ }; const getRoomPresentation = (position: number) => { - return roomPresentations[position] || `${CURRENT_SLIDE_PREFIX}${currentPresentation}`; + if (roomPresentations[position]) return roomPresentations[position]; + return `${CURRENT_SLIDE_PREFIX}${currentPresentation}`; }; const createRoom = () => { @@ -572,7 +577,7 @@ const CreateBreakoutRoomContainer: React.FC = const { data: presentationData } = useDeduplicatedSubscription(PRESENTATIONS_SUBSCRIPTION); const presentations = presentationData?.pres_presentation || []; - const currentPresentation = presentations.find((p) => p.current)?.presentationId || ''; + const currentPresentation = presentations.find((p: Presentation) => p.current)?.presentationId || ''; if (usersLoading || breakoutsLoading || !currentMeeting) { return null; diff --git a/bigbluebutton-html5/imports/ui/components/breakout-room/create-breakout-room/room-managment-state/component.tsx b/bigbluebutton-html5/imports/ui/components/breakout-room/create-breakout-room/room-managment-state/component.tsx index 58c1d8dded..84f95f3727 100644 --- a/bigbluebutton-html5/imports/ui/components/breakout-room/create-breakout-room/room-managment-state/component.tsx +++ b/bigbluebutton-html5/imports/ui/components/breakout-room/create-breakout-room/room-managment-state/component.tsx @@ -6,6 +6,8 @@ import { ChildComponentProps, Room, moveUserRegistery, + Presentation, + RoomPresentations, } from './types'; import { breakoutRoom, getBreakoutsResponse } from '../queries'; @@ -28,6 +30,13 @@ interface RoomManagmentStateProps { setFormIsValid: (isValid: boolean) => void; setRoomsRef: (rooms: Rooms) => void; setMoveRegisterRef: (moveRegister: moveUserRegistery) => void; + presentations: Presentation[]; + roomPresentations: RoomPresentations; + setRoomPresentations: React.Dispatch>; + currentPresentation: string; + currentSlidePrefix: string; + getRoomPresentation: (roomId: number) => string; + isUpdate: boolean; } const RoomManagmentState: React.FC = ({ diff --git a/bigbluebutton-html5/imports/ui/components/breakout-room/create-breakout-room/room-managment-state/types.ts b/bigbluebutton-html5/imports/ui/components/breakout-room/create-breakout-room/room-managment-state/types.ts index 56b2cde0a3..6e7e75b51e 100644 --- a/bigbluebutton-html5/imports/ui/components/breakout-room/create-breakout-room/room-managment-state/types.ts +++ b/bigbluebutton-html5/imports/ui/components/breakout-room/create-breakout-room/room-managment-state/types.ts @@ -47,4 +47,21 @@ export type ChildComponentProps = { randomlyAssign: () => void; resetRooms: (cap: number) => void; users: BreakoutUser[]; + currentSlidePrefix: string; + presentations: Presentation[]; + getRoomPresentation: (roomId: number) => string; + setRoomPresentations: React.Dispatch>; + currentPresentation: string; + roomPresentations: RoomPresentations; + isUpdate: boolean; +} + +export interface Presentation { + presentationId: string; + name: string; + current: boolean; +} + +export interface RoomPresentations { + [roomId: number]: string; }