Lint: fix all the lint errors
This commit is contained in:
@@ -9,12 +9,13 @@ import {
|
||||
catchError,
|
||||
from,
|
||||
map,
|
||||
Observable,
|
||||
type Observable,
|
||||
of,
|
||||
startWith,
|
||||
switchMap,
|
||||
startWith
|
||||
} from "rxjs";
|
||||
|
||||
// TODO where are all the comments? ::cry::
|
||||
// There used to be an unitialized state!, a state might not start in loading
|
||||
export type Async<A> =
|
||||
| { state: "loading" }
|
||||
| { state: "error"; value: Error }
|
||||
@@ -24,21 +25,22 @@ export const loading: Async<never> = { state: "loading" };
|
||||
export function error(value: Error): Async<never> {
|
||||
return { state: "error", value };
|
||||
}
|
||||
|
||||
export function ready<A>(value: A): Async<A> {
|
||||
return { state: "ready", value };
|
||||
}
|
||||
|
||||
export function async<A>(promise: Promise<A>): Observable<Async<A>> {
|
||||
export function async$<A>(promise: Promise<A>): Observable<Async<A>> {
|
||||
return from(promise).pipe(
|
||||
map(ready),
|
||||
startWith(loading),
|
||||
catchError((e) => of(error(e))),
|
||||
catchError((e: unknown) => of(error(e as Error ?? new Error("Unknown error")))),
|
||||
);
|
||||
}
|
||||
|
||||
export function mapAsync<A, B>(
|
||||
async: Async<A>,
|
||||
project: (value: A) => B,
|
||||
project: (value: A) => B
|
||||
): Async<B> {
|
||||
return async.state === "ready" ? ready(project(async.value)) : async;
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ import {
|
||||
type ECConnectionState,
|
||||
} from "../livekit/useECConnectionState";
|
||||
import { E2eeType } from "../e2ee/e2eeType";
|
||||
import type { RaisedHandInfo } from "../reactions";
|
||||
import type { RaisedHandInfo, ReactionInfo } from "../reactions";
|
||||
import {
|
||||
alice,
|
||||
aliceDoppelganger,
|
||||
@@ -95,6 +95,7 @@ import { ObservableScope } from "./ObservableScope";
|
||||
import { MediaDevices } from "./MediaDevices";
|
||||
import { getValue } from "../utils/observable";
|
||||
import { type Behavior, constant } from "./Behavior";
|
||||
import type { ProcessorState } from "../livekit/TrackProcessorContext.tsx";
|
||||
|
||||
const getUrlParams = vi.hoisted(() => vi.fn(() => ({})));
|
||||
vi.mock("../UrlParams", () => ({ getUrlParams }));
|
||||
@@ -341,6 +342,7 @@ function withCallViewModel(
|
||||
.mockImplementation((_room, _eventType) => of());
|
||||
const muteStates = mockMuteStates();
|
||||
const raisedHands$ = new BehaviorSubject<Record<string, RaisedHandInfo>>({});
|
||||
const reactions$ = new BehaviorSubject<Record<string, ReactionInfo>>({});
|
||||
|
||||
const vm = new CallViewModel(
|
||||
rtcSession as unknown as MatrixRTCSession,
|
||||
@@ -349,7 +351,8 @@ function withCallViewModel(
|
||||
muteStates,
|
||||
options,
|
||||
raisedHands$,
|
||||
new BehaviorSubject({}),
|
||||
reactions$,
|
||||
new BehaviorSubject<ProcessorState>({ processor: undefined, supported: undefined }),
|
||||
);
|
||||
|
||||
onTestFinished(() => {
|
||||
|
||||
@@ -132,7 +132,7 @@ import { getUrlParams } from "../UrlParams";
|
||||
import { type ProcessorState } from "../livekit/TrackProcessorContext";
|
||||
import { ElementWidgetActions, widget } from "../widget";
|
||||
import { PublishConnection } from "./PublishConnection.ts";
|
||||
import { type Async, async, mapAsync, ready } from "./Async";
|
||||
import { type Async, async$, mapAsync, ready } from "./Async";
|
||||
|
||||
export interface CallViewModelOptions {
|
||||
encryptionSystem: EncryptionSystem;
|
||||
@@ -520,7 +520,7 @@ export class CallViewModel extends ViewModel {
|
||||
joined
|
||||
? combineLatest(
|
||||
[
|
||||
async(this.preferredTransport),
|
||||
async$(this.preferredTransport),
|
||||
this.memberships$,
|
||||
multiSfu.value$,
|
||||
],
|
||||
@@ -1953,7 +1953,10 @@ export class CallViewModel extends ViewModel {
|
||||
.subscribe(({ start, stop }) => {
|
||||
for (const c of stop) {
|
||||
logger.info(`Disconnecting from ${c.localTransport.livekit_service_url}`);
|
||||
c.stop();
|
||||
c.stop().catch((err) => {
|
||||
// TODO: better error handling
|
||||
logger.error("MuteState: handler error", err);
|
||||
});;
|
||||
}
|
||||
for (const c of start) {
|
||||
c.start().then(
|
||||
|
||||
@@ -6,7 +6,6 @@ Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
import { afterEach, describe, expect, it, type Mock, type MockedObject, vi } from "vitest";
|
||||
import type { CallMembership, LivekitTransport } from "matrix-js-sdk/lib/matrixrtc";
|
||||
import { BehaviorSubject, of } from "rxjs";
|
||||
import {
|
||||
ConnectionState,
|
||||
@@ -18,8 +17,8 @@ import {
|
||||
import fetchMock from "fetch-mock";
|
||||
import EventEmitter from "events";
|
||||
import { type IOpenIDToken } from "matrix-js-sdk";
|
||||
import { type BackgroundOptions, type ProcessorWrapper } from "@livekit/track-processors";
|
||||
|
||||
import type { CallMembership, LivekitTransport } from "matrix-js-sdk/lib/matrixrtc";
|
||||
import { type ConnectionOpts, type FocusConnectionState, RemoteConnection } from "./Connection.ts";
|
||||
import { ObservableScope } from "./ObservableScope.ts";
|
||||
import { type OpenIDClientParts } from "../livekit/openIDSFU.ts";
|
||||
@@ -29,7 +28,6 @@ import { mockMediaDevices, mockMuteStates } from "../utils/test.ts";
|
||||
import type { ProcessorState } from "../livekit/TrackProcessorContext.tsx";
|
||||
import { type MuteStates } from "./MuteStates.ts";
|
||||
|
||||
|
||||
let testScope: ObservableScope;
|
||||
|
||||
let client: MockedObject<OpenIDClientParts>;
|
||||
@@ -551,7 +549,7 @@ describe("Publishing participants observations", () => {
|
||||
});
|
||||
|
||||
|
||||
it("should be scoped to parent scope", async () => {
|
||||
it("should be scoped to parent scope", (): void => {
|
||||
setupTest();
|
||||
|
||||
const connection = setupRemoteConnection();
|
||||
@@ -613,7 +611,7 @@ describe("PublishConnection", () => {
|
||||
let roomFactoryMock: Mock<() => LivekitRoom>;
|
||||
let muteStates: MockedObject<MuteStates>;
|
||||
|
||||
function setUpPublishConnection() {
|
||||
function setUpPublishConnection(): void {
|
||||
setupTest();
|
||||
|
||||
roomFactoryMock = vi.fn().mockReturnValue(fakeLivekitRoom);
|
||||
@@ -673,9 +671,13 @@ describe("PublishConnection", () => {
|
||||
}
|
||||
};
|
||||
|
||||
// TODO understand what is wrong with our mocking that requires ts-expect-error
|
||||
const fakeDevices = mockMediaDevices({
|
||||
// @ts-expect-error Mocking only
|
||||
audioInput,
|
||||
// @ts-expect-error Mocking only
|
||||
videoInput,
|
||||
// @ts-expect-error Mocking only
|
||||
audioOutput
|
||||
});
|
||||
|
||||
|
||||
@@ -88,7 +88,10 @@ class MuteState<Label, Selected> {
|
||||
} else {
|
||||
subscriber.next(enabled);
|
||||
syncing = true;
|
||||
sync();
|
||||
sync().catch((err) => {
|
||||
// TODO: better error handling
|
||||
logger.error("MuteState: handler error", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -97,7 +100,10 @@ class MuteState<Label, Selected> {
|
||||
latestDesired = desired;
|
||||
if (syncing === false) {
|
||||
syncing = true;
|
||||
sync();
|
||||
sync().catch((err) => {
|
||||
// TODO: better error handling
|
||||
logger.error("MuteState: handler error", err);
|
||||
});
|
||||
}
|
||||
});
|
||||
return (): void => s.unsubscribe();
|
||||
@@ -132,6 +138,7 @@ class MuteState<Label, Selected> {
|
||||
) {}
|
||||
}
|
||||
|
||||
// TODO there is another MuteStates in src/room/MuteStates.tsx ?? why
|
||||
export class MuteStates {
|
||||
public readonly audio = new MuteState(
|
||||
this.scope,
|
||||
|
||||
Reference in New Issue
Block a user