Skip to content

Commit 3ac2aa8

Browse files
Half-Shotrobintown
andauthored
Disable call button while the call is connecting. (#3531)
* Disable call button while the call is connecting. * cleanup * fix * Update src/room/LobbyView.tsx Co-authored-by: Robin <[email protected]> * fixup * appease linter --------- Co-authored-by: Robin <[email protected]>
1 parent d24da18 commit 3ac2aa8

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

src/room/GroupCallView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ export const GroupCallView: FC<Props> = ({
436436
client={client}
437437
matrixInfo={matrixInfo}
438438
muteStates={muteStates}
439-
onEnter={() => void enterRTCSessionOrError(rtcSession)}
439+
onEnter={async () => enterRTCSessionOrError(rtcSession)}
440440
confineToRoom={confineToRoom}
441441
hideHeader={header === HeaderStyle.None}
442442
participantCount={participantCount}

src/room/LobbyView.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ interface Props {
5757
client: MatrixClient;
5858
matrixInfo: MatrixInfo;
5959
muteStates: MuteStates;
60-
onEnter: () => void;
60+
onEnter: () => Promise<void>;
6161
enterLabel?: JSX.Element | string;
6262
confineToRoom: boolean;
6363
hideHeader: boolean;
@@ -193,6 +193,14 @@ export const LobbyView: FC<Props> = ({
193193

194194
useTrackProcessorSync(videoTrack);
195195

196+
const [waitingToEnter, setWaitingToEnter] = useState(false);
197+
const onEnterCall = useCallback(() => {
198+
setWaitingToEnter(true);
199+
void onEnter().finally(() => setWaitingToEnter(false));
200+
}, [onEnter]);
201+
202+
const waiting = waitingForInvite || waitingToEnter;
203+
196204
// TODO: Unify this component with InCallView, so we can get slick joining
197205
// animations and don't have to feel bad about reusing its CSS
198206
return (
@@ -222,11 +230,12 @@ export const LobbyView: FC<Props> = ({
222230
>
223231
<Button
224232
className={classNames(styles.join, {
225-
[styles.wait]: waitingForInvite,
233+
[styles.wait]: waiting,
226234
})}
227-
size={waitingForInvite ? "sm" : "lg"}
235+
size={waiting ? "sm" : "lg"}
236+
disabled={waiting}
228237
onClick={() => {
229-
if (!waitingForInvite) onEnter();
238+
if (!waiting) onEnterCall();
230239
}}
231240
data-testid="lobby_joinCall"
232241
>

src/room/RoomPage.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,10 @@ export const RoomPage: FC = () => {
151151
: E2eeType.NONE,
152152
},
153153
}}
154-
onEnter={(): void => knock?.()}
154+
onEnter={async (): Promise<void> => {
155+
knock?.();
156+
return Promise.resolve();
157+
}}
155158
enterLabel={label}
156159
waitingForInvite={groupCallState.kind === "waitForInvite"}
157160
confineToRoom={confineToRoom}

0 commit comments

Comments
 (0)