Adapt delayed leave timings when delegation is available

Splits the config options for the timings of a delayed leave event into two sets: one for when delegation is available (as you can relax the timings and get more stable calls this way), and another for when it's unavailable (as we must continue to gracefully downgrade even after Matrix 2.0 is fully rolled out).

This works by bluntly hitting the delegation endpoints without auth before joining to check for a 404.
This commit is contained in:
Robin
2026-09-07 13:10:54 +02:00
parent a376280c91
commit 6a9583a2ce
13 changed files with 363 additions and 208 deletions
+16 -13
View File
@@ -64,7 +64,10 @@ import {
showReactions,
} from "../../settings/settings";
import { Config } from "../../config/Config";
import { MatrixRTCMode } from "../../config/ConfigOptions";
import {
MatrixRTCMode,
type ResolvedDelayedLeaveTimings,
} from "../../config/ConfigOptions";
import { isFirefox, platform } from "../../Platform";
import { setPipEnabled$ } from "../../controls";
import { TileStore } from "../TileStore";
@@ -562,16 +565,6 @@ export function createCallViewModel$(
localUser: { userId, deviceId },
});
const connectOptions$ = scope.behavior(
matrixRTCMode$.pipe(
map((mode) => ({
encryptMedia: livekitKeyProvider !== undefined,
// TODO. This might need to get called again on each change of matrixRTCMode...
matrixRTCMode: mode,
})),
),
);
const localMembership = createLocalMembership$({
scope,
homeserverConnected: createHomeserverConnected$(
@@ -580,12 +573,21 @@ export function createCallViewModel$(
matrixRTCSession,
),
muteStates,
joinMatrixRTC: (transport: LivekitTransportConfig) => {
joinMatrixRTC: (
transport: LivekitTransportConfig,
delayedLeaveTimings: ResolvedDelayedLeaveTimings,
) => {
return enterRTCSession(
matrixRTCSession,
ownMembershipIdentity,
transport,
connectOptions$.value,
{
encryptMedia: livekitKeyProvider !== undefined,
// We merely sample the current mode here, so the user would need to
// manually rejoin to switch to a different one
matrixRTCMode: matrixRTCMode$.value,
delayedLeaveTimings,
},
);
},
createPublisherFactory: (connection: Connection) => {
@@ -603,6 +605,7 @@ export function createCallViewModel$(
matrixRTCSession,
localTransport$,
roomId: matrixRoom.roomId,
baseUrl: client.baseUrl,
logger: logger.getChild(`[${Date.now()}]`),
});