Skip to content

Commit 1586d24

Browse files
authored
Merge pull request #44 from bigbluebutton/no-layouts-in-plugin
Remove layout selection functionality in plugin to move it to the appliance
2 parents 174fd48 + 1bf2651 commit 1586d24

File tree

3 files changed

+46
-163
lines changed

3 files changed

+46
-163
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,4 @@ venv/
3939
__pycache__
4040
.pytest_cache/
4141

42+
.vscode/settings.json

html-plugin/src/room-media-plugin/RoomMediaPlugin.tsx

Lines changed: 45 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@ import {
1010
ActionButtonDropdownSeparator,
1111
ActionButtonDropdownOption
1212
} from 'bigbluebutton-html-plugin-sdk';
13-
import { RoomConfig, Layout, RoomMediaPluginProps } from './types';
13+
import { RoomConfig, RoomMediaPluginProps } from './types';
1414

1515
import PinComponent from './Shared/PinComponent';
1616
import LoaderComponent from './Shared/LoaderComponent';
17-
import LayoutComponent from './Shared/LayoutComponent';
1817

1918
import { USER_SET_MUTED } from './libs/mutations';
2019

@@ -31,18 +30,14 @@ export function RoomMediaPlugin({ pluginUuid: uuid }: RoomMediaPluginProps) {
3130
};
3231

3332
const webSocketRef = useRef<WebSocket | null>(null);
34-
const [layoutIndex, setLayoutIndex] = useState<number | null>(null);
35-
const [availableLayouts, setAvailableLayouts] = useState<Layout[] | null>(null);
3633
const [roomConfig, setRoomConfig] = useState<RoomConfig | null>(null);
37-
const [isCodeVerified, setIsCodeVerified] = useState<boolean | null>(false);
34+
const [isCodeVerified, setIsCodeVerified] = useState<boolean>(false);
3835
const [verificationCode, setVerificationCode] = useState<string | null>(null);
3936
const [verificationCodeRejected, setVerificationCodeRejected] = useState<boolean>(false);
40-
4137
const [roomJoinUrls, setRoomJoinUrls] = useState(null);
4238
const [pinValue, setPinValue] = useState<string | null>(null);
4339
const [pinError, setPinError] = useState<boolean>(false);
4440
const [isPairing, setIsPairing] = useState<boolean>(false);
45-
const [status, setStatus] = useState<string | null>(null);
4641
const [apolloClient, setApolloClient] = useState<any>(null);
4742
const { data: talkingIndicator } = pluginApi.useTalkingIndicator();
4843
const [isUserMuted, setIsUserMuted] = useState<boolean>(true);
@@ -93,12 +88,8 @@ export function RoomMediaPlugin({ pluginUuid: uuid }: RoomMediaPluginProps) {
9388

9489
if (data.type === 'VerificationCodeAccepted') {
9590
console.debug('Hybrid-Plugin --- Verification Code accepted.');
96-
setIsPairing(false);
97-
setIsCodeVerified(true);
98-
setStatus('layoutSelection');
9991
setRoomConfig(data.roomConfig);
100-
setAvailableLayouts(Object.values(data.roomConfig.layouts));
101-
setPinValue(null);
92+
finalizePairing();
10293
}
10394

10495
if (data.type === 'VerificationCodeRejected') {
@@ -117,6 +108,7 @@ export function RoomMediaPlugin({ pluginUuid: uuid }: RoomMediaPluginProps) {
117108
ws.onclose = (e) => {
118109
console.info('Hybrid-Plugin --- Room Integration Plugin: Closing WebSocket Connection', e);
119110
resetPlugin();
111+
setShowModal(false);
120112
};
121113

122114
webSocketRef.current = ws;
@@ -126,10 +118,9 @@ export function RoomMediaPlugin({ pluginUuid: uuid }: RoomMediaPluginProps) {
126118
setPinValue(null);
127119
setVerificationCode(null);
128120
setVerificationCodeRejected(false);
121+
setIsCodeVerified(false);
129122
setIsPairing(false);
130-
setShowModal(false);
131123
setIsRoomDisconnected(false);
132-
setLayoutIndex(null);
133124
};
134125

135126
const handlePinCompletion = (value: string, index: number): void => {
@@ -156,6 +147,7 @@ export function RoomMediaPlugin({ pluginUuid: uuid }: RoomMediaPluginProps) {
156147
}, [talkingIndicator]);
157148

158149
const muteCurrentUser = async () => {
150+
console.debug('Hybrid-Plugin --- Muting current user');
159151
if (apolloClient && !isUserMuted) {
160152
const result = await apolloClient.mutate({
161153
mutation: USER_SET_MUTED,
@@ -167,16 +159,33 @@ export function RoomMediaPlugin({ pluginUuid: uuid }: RoomMediaPluginProps) {
167159
}
168160
};
169161

170-
const layoutSelection = async (index: number): Promise<void> => {
171-
setStatus('applyingLayout');
172-
await muteCurrentUser();
162+
useEffect(() => {
163+
const fetchJoinUrls = async () => {
164+
if (roomConfig) {
165+
console.debug('Hybrid-Plugin --- Fetching join urls');
166+
const joinUrl: string = await pluginApi.getJoinUrl({
167+
"fullName": roomConfig.bbb_user_name,
168+
"duplicateSession": "false"
169+
});
170+
171+
setRoomJoinUrls({
172+
"type": "JoinURL", "joinUrl": joinUrl, "layoutIndex": 0
173+
});
174+
console.debug('Hybrid-Plugin --- Got Join URL:', joinUrl);
175+
}
176+
};
177+
178+
fetchJoinUrls();
179+
}, [roomConfig]);
180+
181+
const finalizePairing = async () => {
173182
pluginApi.uiCommands.conference.setSpeakerLevel({ level: 0 });
174-
setLayoutIndex(index);
175-
console.debug('Hybrid-Plugin --- Set Layout Index to: ', index);
176-
setStatus('layoutSelected');
177183
setPinError(false);
178184
setPinValue(null);
179185
setShowModal(false);
186+
setIsPairing(false);
187+
setIsCodeVerified(true);
188+
setPinValue(null);
180189
};
181190

182191
const disconnect = async (): Promise<void> => {
@@ -219,28 +228,12 @@ export function RoomMediaPlugin({ pluginUuid: uuid }: RoomMediaPluginProps) {
219228
}
220229
}, [currentUser]);
221230

222-
useEffect(() => {
223-
const fetchJoinUrls = async () => {
224-
if (layoutIndex === null) return;
225-
226-
const joinUrl: string = await pluginApi.getJoinUrl({
227-
"fullName": roomConfig.bbb_user_name,
228-
"duplicateSession": "false"
229-
});
230-
231-
setRoomJoinUrls({
232-
"type": "JoinURL", "joinUrl": joinUrl, "layoutIndex": layoutIndex
233-
});
234-
};
235-
236-
fetchJoinUrls();
237-
}, [layoutIndex]);
238-
239231
useEffect(() => {
240232
try {
241233
if (roomJoinUrls && webSocketRef.current?.readyState === WebSocket.OPEN) {
242234
console.debug('Hybrid-Plugin --- Sending join urls via WebSocket:', JSON.stringify(roomJoinUrls));
243235
webSocketRef.current.send(JSON.stringify(roomJoinUrls));
236+
muteCurrentUser();
244237
}
245238
} catch (error) {
246239
console.error('Hybrid-Plugin --- Room Integration Plugin: Error sending urls via WebSocket:', error);
@@ -273,19 +266,21 @@ export function RoomMediaPlugin({ pluginUuid: uuid }: RoomMediaPluginProps) {
273266
width: '100%', height: '100%', alignItems: 'center', display: 'flex', flexDirection: 'column',
274267
}}
275268
>
276-
277-
{verificationCodeRejected ? ( // Check for verificationCodeRejected first
269+
{verificationCodeRejected ? (
278270
<>
279271
<h4>Verification Code Rejected by Room</h4>
280272
<button
281273
className="button-style"
282274
type="button"
283-
onClick={resetPlugin}
275+
onClick={() => {
276+
resetPlugin();
277+
setShowModal(false);
278+
}}
284279
>
285280
Ok
286281
</button>
287282
</>
288-
) : isRoomDisconnected ? ( // Then check for isRoomDisconnected
283+
) : isRoomDisconnected ? (
289284
<>
290285
<h4>Room Disconnected</h4>
291286
<button
@@ -332,78 +327,17 @@ export function RoomMediaPlugin({ pluginUuid: uuid }: RoomMediaPluginProps) {
332327
</>
333328
) : (
334329
<>
335-
{status ? (
336-
<>
337-
{status == "accepted" && (
338-
<>
339-
<LoaderComponent title="Accepted, loading layouts..." />
340-
<button
341-
className="button-style"
342-
type="button"
343-
onClick={disconnect}
344-
>
345-
Cancel Pairing
346-
</button>
347-
</>
348-
)}
349-
350-
{status == "layoutSelection" && (
351-
<>
352-
<LayoutComponent
353-
layouts={availableLayouts}
354-
layoutIndex={layoutSelection}
355-
/>
356-
<button
357-
className="button-style"
358-
type="button"
359-
onClick={disconnect}
360-
>
361-
Cancel Pairing
362-
</button>
363-
</>
364-
)}
365-
366-
{status == "applyingLayout" && (
367-
<>
368-
<LoaderComponent title="Applying layout..." />
369-
<button
370-
className="button-style"
371-
type="button"
372-
onClick={disconnect}
373-
>
374-
Cancel Pairing
375-
</button>
376-
</>
377-
)}
378-
379-
{status == "layoutSelected" && (
380-
<>
381-
<h3>Room already connected!</h3>
382-
<button
383-
className="button-style"
384-
type="button"
385-
onClick={disconnect}
386-
>
387-
Disconnect
388-
</button>
389-
</>
390-
)}
391-
</>
392-
) : (
393-
<>
394-
<h3>Connection declined</h3>
395-
<button
396-
className="button-style"
397-
type="button"
398-
onClick={() => setShowModal(false)}
399-
>
400-
Close
401-
</button>
402-
</>
403-
)}
330+
<h3>Room "{roomConfig?.bbb_user_name}" is connected!</h3>
331+
<button
332+
className="button-style"
333+
type="button"
334+
onClick={disconnect}
335+
>
336+
Disconnect
337+
</button>
404338
</>
405339
)}
406340
</div>
407341
</ReactModal>
408342
);
409-
}
343+
}

html-plugin/src/room-media-plugin/Shared/LayoutComponent.tsx

Lines changed: 0 additions & 52 deletions
This file was deleted.

0 commit comments

Comments
 (0)