Use the same function for deep equality everywhere
This commit is contained in:
@@ -20,7 +20,7 @@ import { createMediaDeviceObserver } from "@livekit/components-core";
|
|||||||
import { combineLatest, distinctUntilChanged, map, startWith } from "rxjs";
|
import { combineLatest, distinctUntilChanged, map, startWith } from "rxjs";
|
||||||
import { useObservable, useObservableEagerState } from "observable-hooks";
|
import { useObservable, useObservableEagerState } from "observable-hooks";
|
||||||
import { logger } from "matrix-js-sdk/lib/logger";
|
import { logger } from "matrix-js-sdk/lib/logger";
|
||||||
import { isEqual } from "lodash-es";
|
import { deepCompare } from "matrix-js-sdk/lib/utils";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
useSetting,
|
useSetting,
|
||||||
@@ -141,13 +141,16 @@ function useMediaDeviceHandle(
|
|||||||
kind,
|
kind,
|
||||||
() => logger.error("Error creating MediaDeviceObserver"),
|
() => logger.error("Error creating MediaDeviceObserver"),
|
||||||
requestPermissions,
|
requestPermissions,
|
||||||
|
).pipe(
|
||||||
|
startWith([]),
|
||||||
// This Observable emits new values whenever the browser fires a
|
// This Observable emits new values whenever the browser fires a
|
||||||
// MediaDevices 'devicechange' event. One would think, innocently, that
|
// MediaDevices 'devicechange' event. One would think, innocently, that
|
||||||
// a 'devicechange' event means the devices have changed. But as of the
|
// a 'devicechange' event means the devices have changed. But as of the
|
||||||
// time of writing, we are seeing mobile Safari firing spurious
|
// time of writing, we are seeing mobile Safari firing spurious
|
||||||
// 'devicechange' events (where no change has actually occurred) when
|
// 'devicechange' events (where no change has actually occurred) when
|
||||||
// we call MediaDevices.getUserMedia. So, filter by deep equality.
|
// we call MediaDevices.getUserMedia. So, filter by deep equality.
|
||||||
).pipe(startWith([]), distinctUntilChanged<MediaDeviceInfo[]>(isEqual)),
|
distinctUntilChanged<MediaDeviceInfo[]>(deepCompare),
|
||||||
|
),
|
||||||
[kind, requestPermissions],
|
[kind, requestPermissions],
|
||||||
);
|
);
|
||||||
const available = useObservableEagerState(
|
const available = useObservableEagerState(
|
||||||
|
|||||||
@@ -26,11 +26,11 @@ import {
|
|||||||
type RemoteParticipant,
|
type RemoteParticipant,
|
||||||
} from "livekit-client";
|
} from "livekit-client";
|
||||||
import * as ComponentsCore from "@livekit/components-core";
|
import * as ComponentsCore from "@livekit/components-core";
|
||||||
import { isEqual } from "lodash-es";
|
|
||||||
import {
|
import {
|
||||||
type CallMembership,
|
type CallMembership,
|
||||||
type MatrixRTCSession,
|
type MatrixRTCSession,
|
||||||
} from "matrix-js-sdk/lib/matrixrtc";
|
} from "matrix-js-sdk/lib/matrixrtc";
|
||||||
|
import { deepCompare } from "matrix-js-sdk/lib/utils";
|
||||||
|
|
||||||
import { CallViewModel, type Layout } from "./CallViewModel";
|
import { CallViewModel, type Layout } from "./CallViewModel";
|
||||||
import {
|
import {
|
||||||
@@ -200,7 +200,7 @@ function summarizeLayout$(l$: Observable<Layout>): Observable<LayoutSummary> {
|
|||||||
// care about the most recent value for each time step, so discard these
|
// care about the most recent value for each time step, so discard these
|
||||||
// extra values.
|
// extra values.
|
||||||
debounceTime(0),
|
debounceTime(0),
|
||||||
distinctUntilChanged(isEqual),
|
distinctUntilChanged(deepCompare),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user