You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-23 17:02:25 +03:00
correct usage of methods that now became async
Signed-off-by: Timo K <toger5@hotmail.de>
This commit is contained in:
@@ -304,7 +304,10 @@ describe("MatrixRTCSession", () => {
|
|||||||
let sentStateEvent: Promise<void>;
|
let sentStateEvent: Promise<void>;
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
sentStateEvent = new Promise((resolve) => {
|
sentStateEvent = new Promise((resolve) => {
|
||||||
sendStateEventMock = jest.fn(resolve);
|
sendStateEventMock = jest.fn().mockImplementation(() => {
|
||||||
|
resolve();
|
||||||
|
return Promise.resolve({ event_id: "id" });
|
||||||
|
});
|
||||||
});
|
});
|
||||||
sendEventMock = jest.fn().mockResolvedValue(undefined);
|
sendEventMock = jest.fn().mockResolvedValue(undefined);
|
||||||
client.sendStateEvent = sendStateEventMock;
|
client.sendStateEvent = sendStateEventMock;
|
||||||
@@ -349,14 +352,8 @@ describe("MatrixRTCSession", () => {
|
|||||||
|
|
||||||
sess!.joinRoomSession([mockFocus], mockFocus, { notificationType: "ring" });
|
sess!.joinRoomSession([mockFocus], mockFocus, { notificationType: "ring" });
|
||||||
await Promise.race([sentStateEvent, new Promise((resolve) => setTimeout(resolve, 5000))]);
|
await Promise.race([sentStateEvent, new Promise((resolve) => setTimeout(resolve, 5000))]);
|
||||||
const { resolve: r, promise: p } = Promise.withResolvers();
|
|
||||||
sess?.once(MatrixRTCSessionEvent.JoinStateChanged, r);
|
|
||||||
await p;
|
|
||||||
mockRoomState(mockRoom, [{ ...membershipTemplate, user_id: client.getUserId()! }]);
|
mockRoomState(mockRoom, [{ ...membershipTemplate, user_id: client.getUserId()! }]);
|
||||||
sess!.onRTCSessionMemberUpdate();
|
await sess!.onRTCSessionMemberUpdate();
|
||||||
const { resolve, promise } = Promise.withResolvers();
|
|
||||||
sess?.once(MatrixRTCSessionEvent.MembershipsChanged, resolve);
|
|
||||||
await promise;
|
|
||||||
const ownMembershipId = sess?.memberships[0].eventId;
|
const ownMembershipId = sess?.memberships[0].eventId;
|
||||||
|
|
||||||
expect(client.sendEvent).toHaveBeenCalledWith(mockRoom!.roomId, EventType.RTCNotification, {
|
expect(client.sendEvent).toHaveBeenCalledWith(mockRoom!.roomId, EventType.RTCNotification, {
|
||||||
@@ -425,7 +422,8 @@ describe("MatrixRTCSession", () => {
|
|||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
sess!.onRTCSessionMemberUpdate();
|
await sess!.onRTCSessionMemberUpdate();
|
||||||
|
|
||||||
const ownMembershipId = sess?.memberships[0].eventId;
|
const ownMembershipId = sess?.memberships[0].eventId;
|
||||||
expect(sess!.getConsensusCallIntent()).toEqual("audio");
|
expect(sess!.getConsensusCallIntent()).toEqual("audio");
|
||||||
|
|
||||||
@@ -476,13 +474,13 @@ describe("MatrixRTCSession", () => {
|
|||||||
it("doesn't send a notification when joining an existing call", async () => {
|
it("doesn't send a notification when joining an existing call", async () => {
|
||||||
// Add another member to the call so that it is considered an existing call
|
// Add another member to the call so that it is considered an existing call
|
||||||
mockRoomState(mockRoom, [membershipTemplate]);
|
mockRoomState(mockRoom, [membershipTemplate]);
|
||||||
sess!.onRTCSessionMemberUpdate();
|
await sess!.onRTCSessionMemberUpdate();
|
||||||
|
|
||||||
// Simulate a join, including the update to the room state
|
// Simulate a join, including the update to the room state
|
||||||
sess!.joinRoomSession([mockFocus], mockFocus, { notificationType: "ring" });
|
sess!.joinRoomSession([mockFocus], mockFocus, { notificationType: "ring" });
|
||||||
await Promise.race([sentStateEvent, new Promise((resolve) => setTimeout(resolve, 5000))]);
|
await Promise.race([sentStateEvent, new Promise((resolve) => setTimeout(resolve, 5000))]);
|
||||||
mockRoomState(mockRoom, [membershipTemplate, { ...membershipTemplate, user_id: client.getUserId()! }]);
|
mockRoomState(mockRoom, [membershipTemplate, { ...membershipTemplate, user_id: client.getUserId()! }]);
|
||||||
sess!.onRTCSessionMemberUpdate();
|
await sess!.onRTCSessionMemberUpdate();
|
||||||
|
|
||||||
expect(client.sendEvent).not.toHaveBeenCalled();
|
expect(client.sendEvent).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
@@ -494,9 +492,9 @@ describe("MatrixRTCSession", () => {
|
|||||||
// But this time we want to simulate a race condition in which we receive a state event
|
// But this time we want to simulate a race condition in which we receive a state event
|
||||||
// from someone else, starting the call before our own state event has been sent
|
// from someone else, starting the call before our own state event has been sent
|
||||||
mockRoomState(mockRoom, [membershipTemplate]);
|
mockRoomState(mockRoom, [membershipTemplate]);
|
||||||
sess!.onRTCSessionMemberUpdate();
|
await sess!.onRTCSessionMemberUpdate();
|
||||||
mockRoomState(mockRoom, [membershipTemplate, { ...membershipTemplate, user_id: client.getUserId()! }]);
|
mockRoomState(mockRoom, [membershipTemplate, { ...membershipTemplate, user_id: client.getUserId()! }]);
|
||||||
sess!.onRTCSessionMemberUpdate();
|
await sess!.onRTCSessionMemberUpdate();
|
||||||
|
|
||||||
// We assume that the responsibility to send a notification, if any, lies with the other
|
// We assume that the responsibility to send a notification, if any, lies with the other
|
||||||
// participant that won the race
|
// participant that won the race
|
||||||
@@ -511,7 +509,7 @@ describe("MatrixRTCSession", () => {
|
|||||||
|
|
||||||
const onMembershipsChanged = jest.fn();
|
const onMembershipsChanged = jest.fn();
|
||||||
sess.on(MatrixRTCSessionEvent.MembershipsChanged, onMembershipsChanged);
|
sess.on(MatrixRTCSessionEvent.MembershipsChanged, onMembershipsChanged);
|
||||||
sess.onRTCSessionMemberUpdate();
|
await sess.onRTCSessionMemberUpdate();
|
||||||
|
|
||||||
expect(onMembershipsChanged).not.toHaveBeenCalled();
|
expect(onMembershipsChanged).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
@@ -524,8 +522,8 @@ describe("MatrixRTCSession", () => {
|
|||||||
sess.on(MatrixRTCSessionEvent.MembershipsChanged, onMembershipsChanged);
|
sess.on(MatrixRTCSessionEvent.MembershipsChanged, onMembershipsChanged);
|
||||||
|
|
||||||
mockRoomState(mockRoom, []);
|
mockRoomState(mockRoom, []);
|
||||||
sess.onRTCSessionMemberUpdate();
|
|
||||||
|
|
||||||
|
await sess.onRTCSessionMemberUpdate();
|
||||||
expect(onMembershipsChanged).toHaveBeenCalled();
|
expect(onMembershipsChanged).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -708,14 +706,14 @@ describe("MatrixRTCSession", () => {
|
|||||||
|
|
||||||
// member2 leaves triggering key rotation
|
// member2 leaves triggering key rotation
|
||||||
mockRoomState(mockRoom, [membershipTemplate]);
|
mockRoomState(mockRoom, [membershipTemplate]);
|
||||||
sess.onRTCSessionMemberUpdate();
|
await sess.onRTCSessionMemberUpdate();
|
||||||
|
|
||||||
// member2 re-joins which should trigger an immediate re-send
|
// member2 re-joins which should trigger an immediate re-send
|
||||||
const keysSentPromise2 = new Promise<EncryptionKeysEventContent>((resolve) => {
|
const keysSentPromise2 = new Promise<EncryptionKeysEventContent>((resolve) => {
|
||||||
sendEventMock.mockImplementation((_roomId, _evType, payload) => resolve(payload));
|
sendEventMock.mockImplementation((_roomId, _evType, payload) => resolve(payload));
|
||||||
});
|
});
|
||||||
mockRoomState(mockRoom, [membershipTemplate, member2]);
|
mockRoomState(mockRoom, [membershipTemplate, member2]);
|
||||||
sess.onRTCSessionMemberUpdate();
|
await sess.onRTCSessionMemberUpdate();
|
||||||
// but, that immediate resend is throttled so we need to wait a bit
|
// but, that immediate resend is throttled so we need to wait a bit
|
||||||
jest.advanceTimersByTime(1000);
|
jest.advanceTimersByTime(1000);
|
||||||
const { keys } = await keysSentPromise2;
|
const { keys } = await keysSentPromise2;
|
||||||
@@ -766,7 +764,7 @@ describe("MatrixRTCSession", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
mockRoomState(mockRoom, [membershipTemplate, member2]);
|
mockRoomState(mockRoom, [membershipTemplate, member2]);
|
||||||
sess.onRTCSessionMemberUpdate();
|
await sess.onRTCSessionMemberUpdate();
|
||||||
|
|
||||||
await keysSentPromise2;
|
await keysSentPromise2;
|
||||||
|
|
||||||
@@ -813,7 +811,7 @@ describe("MatrixRTCSession", () => {
|
|||||||
sendEventMock.mockClear();
|
sendEventMock.mockClear();
|
||||||
|
|
||||||
// these should be a no-op:
|
// these should be a no-op:
|
||||||
sess.onRTCSessionMemberUpdate();
|
await sess.onRTCSessionMemberUpdate();
|
||||||
expect(sendEventMock).toHaveBeenCalledTimes(0);
|
expect(sendEventMock).toHaveBeenCalledTimes(0);
|
||||||
expect(sess!.statistics.counters.roomEventEncryptionKeysSent).toEqual(1);
|
expect(sess!.statistics.counters.roomEventEncryptionKeysSent).toEqual(1);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -858,7 +856,7 @@ describe("MatrixRTCSession", () => {
|
|||||||
sendEventMock.mockClear();
|
sendEventMock.mockClear();
|
||||||
|
|
||||||
// this should be a no-op:
|
// this should be a no-op:
|
||||||
sess.onRTCSessionMemberUpdate();
|
await sess.onRTCSessionMemberUpdate();
|
||||||
expect(sendEventMock).toHaveBeenCalledTimes(0);
|
expect(sendEventMock).toHaveBeenCalledTimes(0);
|
||||||
|
|
||||||
// advance time to avoid key throttling
|
// advance time to avoid key throttling
|
||||||
@@ -873,7 +871,7 @@ describe("MatrixRTCSession", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// this should re-send the key
|
// this should re-send the key
|
||||||
sess.onRTCSessionMemberUpdate();
|
await sess.onRTCSessionMemberUpdate();
|
||||||
|
|
||||||
await keysSentPromise2;
|
await keysSentPromise2;
|
||||||
|
|
||||||
@@ -931,8 +929,10 @@ describe("MatrixRTCSession", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
mockRoomState(mockRoom, [membershipTemplate]);
|
mockRoomState(mockRoom, [membershipTemplate]);
|
||||||
sess.onRTCSessionMemberUpdate();
|
const { promise, resolve } = Promise.withResolvers();
|
||||||
|
sess.once(MatrixRTCSessionEvent.MembershipsChanged, resolve);
|
||||||
|
await sess.onRTCSessionMemberUpdate();
|
||||||
|
await promise;
|
||||||
jest.advanceTimersByTime(KEY_DELAY);
|
jest.advanceTimersByTime(KEY_DELAY);
|
||||||
expect(sendKeySpy).toHaveBeenCalledTimes(1);
|
expect(sendKeySpy).toHaveBeenCalledTimes(1);
|
||||||
// check that we send the key with index 1 even though the send gets delayed when leaving.
|
// check that we send the key with index 1 even though the send gets delayed when leaving.
|
||||||
@@ -998,7 +998,7 @@ describe("MatrixRTCSession", () => {
|
|||||||
mockRoomState(mockRoom, members.slice(0, membersToTest - i));
|
mockRoomState(mockRoom, members.slice(0, membersToTest - i));
|
||||||
}
|
}
|
||||||
|
|
||||||
sess!.onRTCSessionMemberUpdate();
|
await sess!.onRTCSessionMemberUpdate();
|
||||||
|
|
||||||
// advance time to avoid key throttling
|
// advance time to avoid key throttling
|
||||||
jest.advanceTimersByTime(10000);
|
jest.advanceTimersByTime(10000);
|
||||||
@@ -1037,7 +1037,7 @@ describe("MatrixRTCSession", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
mockRoomState(mockRoom, [membershipTemplate, member2]);
|
mockRoomState(mockRoom, [membershipTemplate, member2]);
|
||||||
sess.onRTCSessionMemberUpdate();
|
await sess.onRTCSessionMemberUpdate();
|
||||||
|
|
||||||
await new Promise((resolve) => {
|
await new Promise((resolve) => {
|
||||||
realSetTimeout(resolve);
|
realSetTimeout(resolve);
|
||||||
@@ -1064,7 +1064,7 @@ describe("MatrixRTCSession", () => {
|
|||||||
manageMediaKeys: true,
|
manageMediaKeys: true,
|
||||||
useExperimentalToDeviceTransport: true,
|
useExperimentalToDeviceTransport: true,
|
||||||
});
|
});
|
||||||
sess.onRTCSessionMemberUpdate();
|
await sess.onRTCSessionMemberUpdate();
|
||||||
|
|
||||||
await keySentPromise;
|
await keySentPromise;
|
||||||
|
|
||||||
|
|||||||
@@ -731,7 +731,7 @@ export class MatrixRTCSession extends TypedEventEmitter<
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (soonestExpiry != undefined) {
|
if (soonestExpiry != undefined) {
|
||||||
this.expiryTimeout = setTimeout(this.onRTCSessionMemberUpdate, soonestExpiry);
|
this.expiryTimeout = setTimeout(() => void this.onRTCSessionMemberUpdate(), soonestExpiry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -803,8 +803,8 @@ export class MatrixRTCSession extends TypedEventEmitter<
|
|||||||
/**
|
/**
|
||||||
* Call this when something changed that may impacts the current MatrixRTC members in this session.
|
* Call this when something changed that may impacts the current MatrixRTC members in this session.
|
||||||
*/
|
*/
|
||||||
public onRTCSessionMemberUpdate = (): void => {
|
public onRTCSessionMemberUpdate = (): Promise<void> => {
|
||||||
void this.recalculateSessionMembers();
|
return this.recalculateSessionMembers();
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -838,7 +838,7 @@ export class MatrixRTCSession extends TypedEventEmitter<
|
|||||||
this.emit(MatrixRTCSessionEvent.MembershipsChanged, oldMemberships, this.memberships);
|
this.emit(MatrixRTCSessionEvent.MembershipsChanged, oldMemberships, this.memberships);
|
||||||
});
|
});
|
||||||
|
|
||||||
void this.membershipManager?.onRTCSessionMemberUpdate(this.memberships);
|
await this.membershipManager?.onRTCSessionMemberUpdate(this.memberships);
|
||||||
// The `ownMembership` will be set when calling `onRTCSessionMemberUpdate`.
|
// The `ownMembership` will be set when calling `onRTCSessionMemberUpdate`.
|
||||||
const ownMembership = this.membershipManager?.ownMembership;
|
const ownMembership = this.membershipManager?.ownMembership;
|
||||||
if (this.pendingNotificationToSend && ownMembership && oldMemberships.length === 0) {
|
if (this.pendingNotificationToSend && ownMembership && oldMemberships.length === 0) {
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ export class MatrixRTCSessionManager extends TypedEventEmitter<MatrixRTCSessionM
|
|||||||
// wasActiveAndKnown = session.memberships.length > 0 and
|
// wasActiveAndKnown = session.memberships.length > 0 and
|
||||||
// nowActive = session.memberships.length
|
// nowActive = session.memberships.length
|
||||||
// Alternatively we would need to setup some event emission when the RTC session ended.
|
// Alternatively we would need to setup some event emission when the RTC session ended.
|
||||||
session.onRTCSessionMemberUpdate();
|
await session.onRTCSessionMemberUpdate();
|
||||||
|
|
||||||
const nowActive = session.memberships.length > 0;
|
const nowActive = session.memberships.length > 0;
|
||||||
|
|
||||||
|
|||||||
@@ -398,7 +398,7 @@ export class MembershipManager
|
|||||||
return this.joinConfig?.useRtcMemberFormat ?? false;
|
return this.joinConfig?.useRtcMemberFormat ?? false;
|
||||||
}
|
}
|
||||||
// LOOP HANDLER:
|
// LOOP HANDLER:
|
||||||
private async membershipLoopHandler(type: MembershipActionType): Promise<ActionUpdate> {
|
private membershipLoopHandler(type: MembershipActionType): Promise<ActionUpdate> {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case MembershipActionType.SendDelayedEvent: {
|
case MembershipActionType.SendDelayedEvent: {
|
||||||
// Before we start we check if we come from a state where we have a delay id.
|
// Before we start we check if we come from a state where we have a delay id.
|
||||||
@@ -418,19 +418,19 @@ export class MembershipManager
|
|||||||
case MembershipActionType.RestartDelayedEvent: {
|
case MembershipActionType.RestartDelayedEvent: {
|
||||||
if (!this.state.delayId) {
|
if (!this.state.delayId) {
|
||||||
// Delay id got reset. This action was used to check if the hs canceled the delayed event when the join state got sent.
|
// Delay id got reset. This action was used to check if the hs canceled the delayed event when the join state got sent.
|
||||||
return createInsertActionUpdate(MembershipActionType.SendDelayedEvent);
|
return Promise.resolve(createInsertActionUpdate(MembershipActionType.SendDelayedEvent));
|
||||||
}
|
}
|
||||||
return this.restartDelayedEvent(this.state.delayId);
|
return this.restartDelayedEvent(this.state.delayId);
|
||||||
}
|
}
|
||||||
case MembershipActionType.SendScheduledDelayedLeaveEvent: {
|
case MembershipActionType.SendScheduledDelayedLeaveEvent: {
|
||||||
// We are already good
|
// We are already good
|
||||||
if (!this.state.hasMemberStateEvent) {
|
if (!this.state.hasMemberStateEvent) {
|
||||||
return { replace: [] };
|
return Promise.resolve({ replace: [] });
|
||||||
}
|
}
|
||||||
if (this.state.delayId) {
|
if (this.state.delayId) {
|
||||||
return this.sendScheduledDelayedLeaveEventOrFallbackToSendLeaveEvent(this.state.delayId);
|
return this.sendScheduledDelayedLeaveEventOrFallbackToSendLeaveEvent(this.state.delayId);
|
||||||
} else {
|
} else {
|
||||||
return createInsertActionUpdate(MembershipActionType.SendLeaveEvent);
|
return Promise.resolve(createInsertActionUpdate(MembershipActionType.SendLeaveEvent));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case MembershipActionType.SendJoinEvent: {
|
case MembershipActionType.SendJoinEvent: {
|
||||||
@@ -442,7 +442,7 @@ export class MembershipManager
|
|||||||
case MembershipActionType.SendLeaveEvent: {
|
case MembershipActionType.SendLeaveEvent: {
|
||||||
// We are good already
|
// We are good already
|
||||||
if (!this.state.hasMemberStateEvent) {
|
if (!this.state.hasMemberStateEvent) {
|
||||||
return { replace: [] };
|
return Promise.resolve({ replace: [] });
|
||||||
}
|
}
|
||||||
// This is only a fallback in case we do not have working delayed events support.
|
// This is only a fallback in case we do not have working delayed events support.
|
||||||
// first we should try to just send the scheduled leave event
|
// first we should try to just send the scheduled leave event
|
||||||
@@ -452,12 +452,12 @@ export class MembershipManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
// HANDLERS (used in the membershipLoopHandler)
|
// HANDLERS (used in the membershipLoopHandler)
|
||||||
private async sendOrResendDelayedLeaveEvent(): Promise<ActionUpdate> {
|
private sendOrResendDelayedLeaveEvent(): Promise<ActionUpdate> {
|
||||||
// We can reach this at the start of a call (where we do not yet have a membership: state.hasMemberStateEvent=false)
|
// We can reach this at the start of a call (where we do not yet have a membership: state.hasMemberStateEvent=false)
|
||||||
// or during a call if the state event canceled our delayed event or caused by an unexpected error that removed our delayed event.
|
// or during a call if the state event canceled our delayed event or caused by an unexpected error that removed our delayed event.
|
||||||
// (Another client could have canceled it, the homeserver might have removed/lost it due to a restart, ...)
|
// (Another client could have canceled it, the homeserver might have removed/lost it due to a restart, ...)
|
||||||
// In the `then` and `catch` block we treat both cases differently. "if (this.state.hasMemberStateEvent) {} else {}"
|
// In the `then` and `catch` block we treat both cases differently. "if (this.state.hasMemberStateEvent) {} else {}"
|
||||||
return await this.client
|
return this.client
|
||||||
._unstable_sendDelayedStateEvent(
|
._unstable_sendDelayedStateEvent(
|
||||||
this.room.roomId,
|
this.room.roomId,
|
||||||
{
|
{
|
||||||
@@ -514,9 +514,9 @@ export class MembershipManager
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private async cancelKnownDelayIdBeforeSendDelayedEvent(delayId: string): Promise<ActionUpdate> {
|
private cancelKnownDelayIdBeforeSendDelayedEvent(delayId: string): Promise<ActionUpdate> {
|
||||||
// Remove all running updates and restarts
|
// Remove all running updates and restarts
|
||||||
return await this.client
|
return this.client
|
||||||
._unstable_updateDelayedEvent(delayId, UpdateDelayedEventAction.Cancel)
|
._unstable_updateDelayedEvent(delayId, UpdateDelayedEventAction.Cancel)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.state.delayId = undefined;
|
this.state.delayId = undefined;
|
||||||
@@ -557,7 +557,7 @@ export class MembershipManager
|
|||||||
this.emit(MembershipManagerEvent.ProbablyLeft, this.state.probablyLeft);
|
this.emit(MembershipManagerEvent.ProbablyLeft, this.state.probablyLeft);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async restartDelayedEvent(delayId: string): Promise<ActionUpdate> {
|
private restartDelayedEvent(delayId: string): Promise<ActionUpdate> {
|
||||||
// Compute the duration until we expect the server to send the delayed leave event.
|
// Compute the duration until we expect the server to send the delayed leave event.
|
||||||
const durationUntilServerDelayedLeave = this.state.expectedServerDelayLeaveTs
|
const durationUntilServerDelayedLeave = this.state.expectedServerDelayLeaveTs
|
||||||
? this.state.expectedServerDelayLeaveTs - Date.now()
|
? this.state.expectedServerDelayLeaveTs - Date.now()
|
||||||
@@ -579,7 +579,7 @@ export class MembershipManager
|
|||||||
|
|
||||||
// The obvious choice here would be to use the `IRequestOpts` to set the timeout. Since this call might be forwarded
|
// The obvious choice here would be to use the `IRequestOpts` to set the timeout. Since this call might be forwarded
|
||||||
// to the widget driver this information would get lost. That is why we mimic the AbortError using the race.
|
// to the widget driver this information would get lost. That is why we mimic the AbortError using the race.
|
||||||
return await Promise.race([
|
return Promise.race([
|
||||||
this.client._unstable_updateDelayedEvent(delayId, UpdateDelayedEventAction.Restart),
|
this.client._unstable_updateDelayedEvent(delayId, UpdateDelayedEventAction.Restart),
|
||||||
abortPromise,
|
abortPromise,
|
||||||
])
|
])
|
||||||
@@ -618,8 +618,8 @@ export class MembershipManager
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private async sendScheduledDelayedLeaveEventOrFallbackToSendLeaveEvent(delayId: string): Promise<ActionUpdate> {
|
private sendScheduledDelayedLeaveEventOrFallbackToSendLeaveEvent(delayId: string): Promise<ActionUpdate> {
|
||||||
return await this.client
|
return this.client
|
||||||
._unstable_updateDelayedEvent(delayId, UpdateDelayedEventAction.Send)
|
._unstable_updateDelayedEvent(delayId, UpdateDelayedEventAction.Send)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.state.hasMemberStateEvent = false;
|
this.state.hasMemberStateEvent = false;
|
||||||
@@ -646,8 +646,8 @@ export class MembershipManager
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private async sendJoinEvent(): Promise<ActionUpdate> {
|
private sendJoinEvent(): Promise<ActionUpdate> {
|
||||||
return await this.client
|
return this.client
|
||||||
.sendStateEvent(
|
.sendStateEvent(
|
||||||
this.room.roomId,
|
this.room.roomId,
|
||||||
this.useRtcMemberFormat ? EventType.RTCMembership : EventType.GroupCallMemberPrefix,
|
this.useRtcMemberFormat ? EventType.RTCMembership : EventType.GroupCallMemberPrefix,
|
||||||
@@ -691,9 +691,9 @@ export class MembershipManager
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private async updateExpiryOnJoinedEvent(): Promise<ActionUpdate> {
|
private updateExpiryOnJoinedEvent(): Promise<ActionUpdate> {
|
||||||
const nextExpireUpdateIteration = this.state.expireUpdateIterations + 1;
|
const nextExpireUpdateIteration = this.state.expireUpdateIterations + 1;
|
||||||
return await this.client
|
return this.client
|
||||||
.sendStateEvent(
|
.sendStateEvent(
|
||||||
this.room.roomId,
|
this.room.roomId,
|
||||||
this.useRtcMemberFormat ? EventType.RTCMembership : EventType.GroupCallMemberPrefix,
|
this.useRtcMemberFormat ? EventType.RTCMembership : EventType.GroupCallMemberPrefix,
|
||||||
@@ -720,8 +720,8 @@ export class MembershipManager
|
|||||||
throw e;
|
throw e;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
private async sendFallbackLeaveEvent(): Promise<ActionUpdate> {
|
private sendFallbackLeaveEvent(): Promise<ActionUpdate> {
|
||||||
return await this.client
|
return this.client
|
||||||
.sendStateEvent(
|
.sendStateEvent(
|
||||||
this.room.roomId,
|
this.room.roomId,
|
||||||
this.useRtcMemberFormat ? EventType.RTCMembership : EventType.GroupCallMemberPrefix,
|
this.useRtcMemberFormat ? EventType.RTCMembership : EventType.GroupCallMemberPrefix,
|
||||||
|
|||||||
Reference in New Issue
Block a user