Skip to content

Commit

Permalink
Refactor to defer passing Meeting to onLeaveQueue
Browse files Browse the repository at this point in the history
  • Loading branch information
ssciolla committed Feb 17, 2021
1 parent ec25258 commit a3b5afe
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions src/assets/src/components/queue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { Alert, Button, Card, Col, Modal, Row } from "react-bootstrap";
import Dialog from "react-bootstrap-dialog";

import {
BluejeansMetadata, EnabledBackendName, MeetingBackend, MeetingStatus, MyUser, QueueAttendee,
User, VideoBackendNames, ZoomMetadata
BluejeansMetadata, EnabledBackendName, Meeting, MeetingBackend, MeetingStatus, MyUser,
QueueAttendee, User, VideoBackendNames, ZoomMetadata
} from "../models";
import {
checkForbiddenError, Breadcrumbs, DateTimeDisplay, DisabledMessage, EditToggleField, ErrorDisplay,
Expand Down Expand Up @@ -59,7 +59,7 @@ interface QueueAttendingProps {
joinedQueue?: QueueAttendee | null;
disabled: boolean;
onJoinQueue: (backend: string) => void;
onLeaveQueue: () => void;
onLeaveQueue: (myMeeting: Meeting) => void;
onLeaveAndJoinQueue: (backend: string) => void;
onChangeAgenda: (agenda: string) => void;
onShowDialog: () => void;
Expand Down Expand Up @@ -256,7 +256,7 @@ function QueueAttendingJoined(props: QueueAttendingProps) {
<Button
variant='link'
type='button'
onClick={() => props.onLeaveQueue()}
onClick={() => props.onLeaveQueue(meeting)}
disabled={props.disabled}
aria-label={leaveButtonText}
>
Expand Down Expand Up @@ -446,8 +446,8 @@ export function QueuePage(props: PageProps<QueuePageParams>) {
await api.removeMeeting(queue!.my_meeting!.id);
}
const [doLeaveQueue, leaveQueueLoading, leaveQueueError] = usePromise(leaveQueue);
const confirmLeaveQueue = (queueStatus: 'open' | 'closed', meetingStatus: MeetingStatus | undefined) => {
const dialogParts = (meetingStatus !== undefined && meetingStatus === MeetingStatus.STARTED)
const confirmLeaveQueue = (queueStatus: 'open' | 'closed', meetingStatus: MeetingStatus) => {
const dialogParts = (meetingStatus === MeetingStatus.STARTED)
? {
title: 'Cancel Meeting?',
action: 'cancel the meeting',
Expand Down Expand Up @@ -507,12 +507,23 @@ export function QueuePage(props: PageProps<QueuePageParams>) {
const loadingDisplay = <LoadingDisplay loading={isChanging}/>
const errorDisplay = <ErrorDisplay formErrors={errorSources}/>
const queueDisplay = queue && selectedBackend
&& <QueueAttending queue={queue} backends={props.backends} user={props.user} joinedQueue={myUser?.my_queue}
disabled={isChanging} onJoinQueue={doJoinQueue} onLeaveQueue={() => confirmLeaveQueue(queue.status, queue.my_meeting?.status)}
onLeaveAndJoinQueue={doLeaveAndJoinQueue} onChangeAgenda={doChangeAgenda}
onShowDialog={() => setShowMeetingTypeDialog(true)}
onChangeBackendType={doChangeBackendType}
selectedBackend={selectedBackend} onChangeBackend={setSelectedBackend}/>
&& (
<QueueAttending
queue={queue}
backends={props.backends}
user={props.user}
joinedQueue={myUser?.my_queue}
disabled={isChanging}
onJoinQueue={doJoinQueue}
onLeaveQueue={(myMeeting: Meeting) => confirmLeaveQueue(queue.status, myMeeting.status)}
onLeaveAndJoinQueue={doLeaveAndJoinQueue}
onChangeAgenda={doChangeAgenda}
onShowDialog={() => setShowMeetingTypeDialog(true)}
onChangeBackendType={doChangeBackendType}
selectedBackend={selectedBackend}
onChangeBackend={setSelectedBackend}
/>
);
const meetingTypeDialog = queue && selectedBackend
&& <ChangeMeetingTypeDialog queue={queue} backends={props.backends} show={showMeetingTypeDialog}
onClose={() => setShowMeetingTypeDialog(false)}
Expand Down

0 comments on commit a3b5afe

Please sign in to comment.