review: rename variable

This commit is contained in:
Timo
2025-05-14 18:19:27 +02:00
parent c49fc75756
commit c33fa9844b

View File

@@ -60,7 +60,7 @@ async function doConnect(
sfuConfig: SFUConfig, sfuConfig: SFUConfig,
audioEnabled: boolean, audioEnabled: boolean,
initialDeviceId: string | undefined, initialDeviceId: string | undefined,
cancellable: AbortHandle, abortHandle: AbortHandle,
): Promise<void> { ): Promise<void> {
// Always create an audio track manually. // Always create an audio track manually.
// livekit (by default) keeps the mic track open when you mute, but if you start muted, // livekit (by default) keeps the mic track open when you mute, but if you start muted,
@@ -93,7 +93,7 @@ async function doConnect(
} }
// There was a yield point previously (awaiting for the track to be created) so we need to check // There was a yield point previously (awaiting for the track to be created) so we need to check
// if the operation was cancelled and stop connecting if needed. // if the operation was cancelled and stop connecting if needed.
if (cancellable.isAborted()) { if (abortHandle.isAborted()) {
logger.info( logger.info(
"[Lifecycle] Signal Aborted: Pre-created audio track but connection aborted", "[Lifecycle] Signal Aborted: Pre-created audio track but connection aborted",
); );
@@ -109,7 +109,7 @@ async function doConnect(
if (!audioEnabled) { if (!audioEnabled) {
await preCreatedAudioTrack?.mute(); await preCreatedAudioTrack?.mute();
// There was a yield point. Check if the operation was cancelled and stop connecting. // There was a yield point. Check if the operation was cancelled and stop connecting.
if (cancellable.isAborted()) { if (abortHandle.isAborted()) {
logger.info( logger.info(
"[Lifecycle] Signal Aborted: Pre-created audio track but connection aborted", "[Lifecycle] Signal Aborted: Pre-created audio track but connection aborted",
); );
@@ -132,7 +132,7 @@ async function doConnect(
logger.info("[Lifecycle] Connecting & publishing"); logger.info("[Lifecycle] Connecting & publishing");
try { try {
await connectAndPublish(livekitRoom, sfuConfig, preCreatedAudioTrack, []); await connectAndPublish(livekitRoom, sfuConfig, preCreatedAudioTrack, []);
if (cancellable.isAborted()) { if (abortHandle.isAborted()) {
logger.info( logger.info(
"[Lifecycle] Signal Aborted: Connected but operation was cancelled. Force disconnect", "[Lifecycle] Signal Aborted: Connected but operation was cancelled. Force disconnect",
); );
@@ -291,8 +291,8 @@ export function useECConnectionState(
useEffect(() => { useEffect(() => {
const bag = abortHandlesBag.current; const bag = abortHandlesBag.current;
return (): void => { return (): void => {
bag.forEach((cancellable) => { bag.forEach((handle) => {
cancellable.abort(); handle.abort();
}); });
}; };
}, []); }, []);
@@ -323,14 +323,14 @@ export function useECConnectionState(
// always capturing audio: it helps keep bluetooth headsets in the right mode and // always capturing audio: it helps keep bluetooth headsets in the right mode and
// mobile browsers to know we're doing a call. // mobile browsers to know we're doing a call.
setIsInDoConnect(true); setIsInDoConnect(true);
const cancellable = new AbortHandle(); const abortHandle = new AbortHandle();
abortHandlesBag.current.add(cancellable); abortHandlesBag.current.add(abortHandle);
doConnect( doConnect(
livekitRoom!, livekitRoom!,
sfuConfig!, sfuConfig!,
initialAudioEnabled, initialAudioEnabled,
initialDeviceId, initialDeviceId,
cancellable, abortHandle,
) )
.catch((e) => { .catch((e) => {
if (e instanceof ElementCallError) { if (e instanceof ElementCallError) {
@@ -340,7 +340,7 @@ export function useECConnectionState(
} else logger.error("Failed to connect to SFU", e); } else logger.error("Failed to connect to SFU", e);
}) })
.finally(() => { .finally(() => {
abortHandlesBag.current.delete(cancellable); abortHandlesBag.current.delete(abortHandle);
setIsInDoConnect(false); setIsInDoConnect(false);
}); });
} }