mirror of
https://github.com/vector-im/element-call.git
synced 2026-08-29 21:15:19 +00:00
Expose livekitConnectionState directly
This commit is contained in:
@@ -25,7 +25,11 @@ import useMeasure from "react-use-measure";
|
|||||||
import { type MatrixRTCSession } from "matrix-js-sdk/lib/matrixrtc";
|
import { type MatrixRTCSession } from "matrix-js-sdk/lib/matrixrtc";
|
||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
import { BehaviorSubject, map } from "rxjs";
|
import { BehaviorSubject, map } from "rxjs";
|
||||||
import { useObservable, useSubscription } from "observable-hooks";
|
import {
|
||||||
|
useObservable,
|
||||||
|
useObservableEagerState,
|
||||||
|
useSubscription,
|
||||||
|
} from "observable-hooks";
|
||||||
import { logger } from "matrix-js-sdk/lib/logger";
|
import { logger } from "matrix-js-sdk/lib/logger";
|
||||||
import { RoomAndToDeviceEvents } from "matrix-js-sdk/lib/matrixrtc/RoomAndToDeviceKeyTransport";
|
import { RoomAndToDeviceEvents } from "matrix-js-sdk/lib/matrixrtc/RoomAndToDeviceKeyTransport";
|
||||||
import {
|
import {
|
||||||
@@ -249,7 +253,7 @@ export const InCallView: FC<InCallViewProps> = ({
|
|||||||
useReactionsSender();
|
useReactionsSender();
|
||||||
|
|
||||||
useWakeLock();
|
useWakeLock();
|
||||||
const isDisconnected = useBehavior(vm.livekitDisconnected$);
|
const isDisconnected = useObservableEagerState(vm.livekitConnectionState$);
|
||||||
|
|
||||||
// annoyingly we don't get the disconnection reason this way,
|
// annoyingly we don't get the disconnection reason this way,
|
||||||
// only by listening for the emitted event
|
// only by listening for the emitted event
|
||||||
|
|||||||
@@ -465,14 +465,6 @@ export class CallViewModel extends ViewModel {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
public readonly livekitDisconnected$ = this.scope.behavior(
|
|
||||||
and$(
|
|
||||||
this.livekitConnectionState$.pipe(
|
|
||||||
map((state) => state === ConnectionState.Disconnected),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
private readonly connected$ = this.scope.behavior(
|
private readonly connected$ = this.scope.behavior(
|
||||||
and$(
|
and$(
|
||||||
this.matrixConnected$,
|
this.matrixConnected$,
|
||||||
@@ -969,11 +961,11 @@ export class CallViewModel extends ViewModel {
|
|||||||
"unknown" | "ringing" | "timeout" | "decline" | "success"
|
"unknown" | "ringing" | "timeout" | "decline" | "success"
|
||||||
>(
|
>(
|
||||||
combineLatest([
|
combineLatest([
|
||||||
this.livekitDisconnected$,
|
this.livekitConnectionState$,
|
||||||
this.someoneElseJoined$,
|
this.someoneElseJoined$,
|
||||||
]).pipe(
|
]).pipe(
|
||||||
switchMap(([disconnected, someoneElseJoined]) => {
|
switchMap(([livekitConnectionState, someoneElseJoined]) => {
|
||||||
if (disconnected) {
|
if (livekitConnectionState === ConnectionState.Disconnected) {
|
||||||
// Do not ring until we're connected.
|
// Do not ring until we're connected.
|
||||||
return of("unknown" as const);
|
return of("unknown" as const);
|
||||||
} else if (someoneElseJoined) {
|
} else if (someoneElseJoined) {
|
||||||
@@ -1698,7 +1690,7 @@ export class CallViewModel extends ViewModel {
|
|||||||
private readonly livekitRoom: LivekitRoom,
|
private readonly livekitRoom: LivekitRoom,
|
||||||
private readonly mediaDevices: MediaDevices,
|
private readonly mediaDevices: MediaDevices,
|
||||||
private readonly options: CallViewModelOptions,
|
private readonly options: CallViewModelOptions,
|
||||||
private readonly livekitConnectionState$: Observable<ECConnectionState>,
|
public readonly livekitConnectionState$: Observable<ECConnectionState>,
|
||||||
private readonly handsRaisedSubject$: Observable<
|
private readonly handsRaisedSubject$: Observable<
|
||||||
Record<string, RaisedHandInfo>
|
Record<string, RaisedHandInfo>
|
||||||
>,
|
>,
|
||||||
|
|||||||
Reference in New Issue
Block a user