Skip to content

Commit

Permalink
Add fetching the well known in embedded mode.
Browse files Browse the repository at this point in the history
This is used to load the focus from the well known in elment-call.
  • Loading branch information
toger5 committed Jun 19, 2024
1 parent 819fc75 commit 5c0e719
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7410,7 +7410,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
return this.http.authedRequest(Method.Post, path, undefined, undefined, { prefix: "" });
}

private async fetchClientWellKnown(): Promise<void> {
public async fetchClientWellKnown(): Promise<void> {
// `getRawClientConfig` does not throw or reject on network errors, instead
// it absorbs errors and returns `{}`.
this.clientWellKnownPromise = AutoDiscovery.getRawClientConfig(this.getDomain() ?? undefined);
Expand Down
8 changes: 8 additions & 0 deletions src/embedded.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,14 @@ export class RoomWidgetClient extends MatrixClient {
});
}) ?? [],
);

if (opts.clientWellKnownPollPeriod !== undefined) {
this.clientWellKnownIntervalID = setInterval(() => {
this.fetchClientWellKnown();
}, 1000 * opts.clientWellKnownPollPeriod);
this.fetchClientWellKnown();
}

this.setSyncState(SyncState.Syncing);
logger.info("Finished backfilling events");

Expand Down
5 changes: 3 additions & 2 deletions src/matrixrtc/MatrixRTCSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,8 @@ export class MatrixRTCSession extends TypedEventEmitter<MatrixRTCSessionEvent, M

const myCallMemberEvent = roomState.getStateEvents(EventType.GroupCallMemberPrefix, localUserId) ?? undefined;
const content = myCallMemberEvent?.getContent() ?? {};
const legacy = "memberships" in content || this.useLegacyMemberEvents;
const legacy =
(("memberships" in content && content.membership?.length) ?? 0 > 0) || this.useLegacyMemberEvents;
let newContent: {} | ExperimentalGroupCallRoomMemberState | SessionMembershipData = {};
if (legacy) {
let myPrevMembership: CallMembership | undefined;
Expand Down Expand Up @@ -866,7 +867,7 @@ export class MatrixRTCSession extends TypedEventEmitter<MatrixRTCSessionEvent, M
this.room.roomId,
EventType.GroupCallMemberPrefix,
newContent,
this.useLegacyMemberEvents ? localUserId : `${localUserId}_${localDeviceId}`,
legacy ? localUserId : `_${localUserId}_${localDeviceId}`,
);
logger.info(`Sent updated call member event.`);

Expand Down

0 comments on commit 5c0e719

Please sign in to comment.