mirror of
https://github.com/vector-im/element-call.git
synced 2026-08-29 21:15:19 +00:00
Remove redundant fix for spurious focus changes
We've now fixed it at the source by prohibiting state changes in useActiveLivekitFocus itself.
This commit is contained in:
@@ -8,7 +8,7 @@ Please see LICENSE in the repository root for full details.
|
|||||||
import { type IOpenIDToken, type MatrixClient } from "matrix-js-sdk";
|
import { type IOpenIDToken, type MatrixClient } from "matrix-js-sdk";
|
||||||
import { logger } from "matrix-js-sdk/lib/logger";
|
import { logger } from "matrix-js-sdk/lib/logger";
|
||||||
import { type MatrixRTCSession } from "matrix-js-sdk/lib/matrixrtc";
|
import { type MatrixRTCSession } from "matrix-js-sdk/lib/matrixrtc";
|
||||||
import { useEffect, useRef, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { type LivekitFocus } from "matrix-js-sdk/lib/matrixrtc";
|
import { type LivekitFocus } from "matrix-js-sdk/lib/matrixrtc";
|
||||||
|
|
||||||
import { useActiveLivekitFocus } from "../room/useActiveFocus";
|
import { useActiveLivekitFocus } from "../room/useActiveFocus";
|
||||||
@@ -41,18 +41,12 @@ export function useOpenIDSFU(
|
|||||||
const [sfuConfig, setSFUConfig] = useState<SFUConfig | undefined>(undefined);
|
const [sfuConfig, setSFUConfig] = useState<SFUConfig | undefined>(undefined);
|
||||||
|
|
||||||
const activeFocus = useActiveLivekitFocus(rtcSession);
|
const activeFocus = useActiveLivekitFocus(rtcSession);
|
||||||
|
|
||||||
// TODO: this is an ugly workaround to avoid re-requesting a new jwt token when there is no change in the active focus.
|
|
||||||
// We have a problem with the hooks here. The root problem should be fixed.
|
|
||||||
const currentFocus = useRef(Object.assign({}, activeFocus));
|
|
||||||
|
|
||||||
const { showErrorBoundary } = useErrorBoundary();
|
const { showErrorBoundary } = useErrorBoundary();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (activeFocus && !liveKitFocusEquals(activeFocus, currentFocus.current)) {
|
if (activeFocus) {
|
||||||
getSFUConfigWithOpenID(client, activeFocus).then(
|
getSFUConfigWithOpenID(client, activeFocus).then(
|
||||||
(sfuConfig) => {
|
(sfuConfig) => {
|
||||||
currentFocus.current = Object.assign({}, activeFocus);
|
|
||||||
setSFUConfig(sfuConfig);
|
setSFUConfig(sfuConfig);
|
||||||
},
|
},
|
||||||
(e) => {
|
(e) => {
|
||||||
@@ -61,7 +55,6 @@ export function useOpenIDSFU(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
currentFocus.current = {} as LivekitFocus;
|
|
||||||
setSFUConfig(undefined);
|
setSFUConfig(undefined);
|
||||||
}
|
}
|
||||||
}, [client, activeFocus, showErrorBoundary]);
|
}, [client, activeFocus, showErrorBoundary]);
|
||||||
@@ -69,20 +62,6 @@ export function useOpenIDSFU(
|
|||||||
return sfuConfig;
|
return sfuConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function liveKitFocusEquals(
|
|
||||||
a?: LivekitFocus,
|
|
||||||
b?: LivekitFocus,
|
|
||||||
): boolean {
|
|
||||||
if (a === undefined && b === undefined) return true;
|
|
||||||
if (a === undefined || b === undefined) return false;
|
|
||||||
|
|
||||||
return (
|
|
||||||
a.type === b.type &&
|
|
||||||
a.livekit_service_url === b.livekit_service_url &&
|
|
||||||
a.livekit_alias === b.livekit_alias
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getSFUConfigWithOpenID(
|
export async function getSFUConfigWithOpenID(
|
||||||
client: OpenIDClientParts,
|
client: OpenIDClientParts,
|
||||||
activeFocus: LivekitFocus,
|
activeFocus: LivekitFocus,
|
||||||
|
|||||||
Reference in New Issue
Block a user