diff --git a/src/main.tsx b/src/main.tsx index 06275f59..e795a13c 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -60,9 +60,9 @@ if (fatalError !== null) { Initializer.initBeforeReact() .then(() => { root.render( - - - , + // + , + // , ); }) .catch((e) => { diff --git a/src/room/InCallView.tsx b/src/room/InCallView.tsx index e12fc060..1c8b41e9 100644 --- a/src/room/InCallView.tsx +++ b/src/room/InCallView.tsx @@ -107,7 +107,6 @@ import { import { ReactionsReader } from "../reactions/ReactionsReader"; import { useTypedEventEmitter } from "../useEvents.ts"; import { muteAllAudio$ } from "../state/MuteAllAudioModel.ts"; -import { useMatrixRTCSessionMemberships } from "../useMatrixRTCSessionMemberships.ts"; import { useMediaDevices } from "../MediaDevicesContext.ts"; import { EarpieceOverlay } from "./EarpieceOverlay.tsx"; import { useAppBarHidden, useAppBarSecondaryButton } from "../AppBar.tsx"; @@ -251,7 +250,6 @@ export const InCallView: FC = ({ useExperimentalToDeviceTransportSetting, ); const encryptionSystem = useRoomEncryptionSystem(matrixRoom.roomId); - const memberships = useMatrixRTCSessionMemberships(rtcSession); const showToDeviceEncryption = useMemo( () => diff --git a/src/state/CallViewModel.ts b/src/state/CallViewModel.ts index 623e9e9e..bade6ef9 100644 --- a/src/state/CallViewModel.ts +++ b/src/state/CallViewModel.ts @@ -42,6 +42,7 @@ import { distinctUntilChanged, endWith, filter, + from, fromEvent, ignoreElements, map, @@ -367,6 +368,7 @@ class UserMedia { public destroy(): void { this.scope.end(); + this.vm.destroy(); } } @@ -473,12 +475,17 @@ class Connection { public async startPublishing(): Promise { this.stopped = false; const { url, jwt } = await this.sfuConfig; - if (!this.stopped) - // TODO-MULTI-SFU this should not create a track? - await this.livekitRoom.localParticipant.createTracks({ - audio: { deviceId: "default" }, - }); if (!this.stopped) await this.livekitRoom.connect(url, jwt); + if (!this.stopped) { + const tracks = await this.livekitRoom.localParticipant.createTracks({ + audio: { deviceId: "default" }, + video: true, + }); + for (const track of tracks) { + await this.livekitRoom.localParticipant.publishTrack(track); + } + // await this.livekitRoom.localParticipant.enableCameraAndMicrophone(); + } } private stopped = false; @@ -1814,7 +1821,17 @@ export class CallViewModel extends ViewModel { ) { super(); - void this.localConnection.then((c) => void c.startPublishing()); + void from(this.localConnection) + .pipe(this.scope.bind()) + .subscribe( + (c) => + void c + .startPublishing() + // eslint-disable-next-line no-console + .then(() => console.log("successfully started publishing")) + // eslint-disable-next-line no-console + .catch((e) => console.error("failed to start publishing", e)), + ); this.connectionInstructions$ .pipe(this.scope.bind()) .subscribe(({ start, stop }) => {