You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-08-09 10:22:46 +03:00
This reverts commit 685ef791c8
.
This commit is contained in:
committed by
GitHub
parent
685ef791c8
commit
5bc132a24c
@@ -85,9 +85,7 @@ describe("CallMembership", () => {
|
|||||||
|
|
||||||
it("considers memberships expired when local age large", () => {
|
it("considers memberships expired when local age large", () => {
|
||||||
const fakeEvent = makeMockEvent(1000);
|
const fakeEvent = makeMockEvent(1000);
|
||||||
const evAge = 6000;
|
fakeEvent.getLocalAge = jest.fn().mockReturnValue(6000);
|
||||||
fakeEvent.getLocalAge = jest.fn().mockReturnValue(evAge);
|
|
||||||
fakeEvent.localTimestamp = Date.now() - evAge;
|
|
||||||
const membership = new CallMembership(fakeEvent, membershipTemplate);
|
const membership = new CallMembership(fakeEvent, membershipTemplate);
|
||||||
expect(membership.isExpired()).toEqual(true);
|
expect(membership.isExpired()).toEqual(true);
|
||||||
});
|
});
|
||||||
|
@@ -61,7 +61,7 @@ export function mockRTCEvent(
|
|||||||
getSender: jest.fn().mockReturnValue("@mock:user.example"),
|
getSender: jest.fn().mockReturnValue("@mock:user.example"),
|
||||||
getTs: jest.fn().mockReturnValue(1000),
|
getTs: jest.fn().mockReturnValue(1000),
|
||||||
getLocalAge: getLocalAgeFn,
|
getLocalAge: getLocalAgeFn,
|
||||||
localTimestamp: Date.now() - getLocalAgeFn(),
|
localTimestamp: Date.now(),
|
||||||
getRoomId: jest.fn().mockReturnValue(roomId),
|
getRoomId: jest.fn().mockReturnValue(roomId),
|
||||||
sender: {
|
sender: {
|
||||||
userId: "@mock:user.example",
|
userId: "@mock:user.example",
|
||||||
|
@@ -91,7 +91,7 @@ export class CallMembership {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public isExpired(): boolean {
|
public isExpired(): boolean {
|
||||||
return this.getMsUntilExpiry() <= 0;
|
return this.getAbsoluteExpiry() < this.parentEvent.getTs() + this.parentEvent.getLocalAge();
|
||||||
}
|
}
|
||||||
|
|
||||||
public getActiveFoci(): Focus[] {
|
public getActiveFoci(): Focus[] {
|
||||||
|
@@ -392,7 +392,7 @@ export class MatrixEvent extends TypedEventEmitter<MatrixEventEmittedEvents, Mat
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.txnId = event.txn_id;
|
this.txnId = event.txn_id;
|
||||||
this.localTimestamp = Date.now() - (this.getAge() ?? this.fallbackAge());
|
this.localTimestamp = Date.now() - (this.getAge() ?? 0);
|
||||||
this.reEmitter = new TypedReEmitter(this);
|
this.reEmitter = new TypedReEmitter(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -663,21 +663,6 @@ export class MatrixEvent extends TypedEventEmitter<MatrixEventEmittedEvents, Mat
|
|||||||
return this.getUnsigned().age || this.event.age; // v2 / v1
|
return this.getUnsigned().age || this.event.age; // v2 / v1
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The fallbackAge is computed by using the origin_server_ts. So it is not adjusted
|
|
||||||
* to the local device clock. It should never be used.
|
|
||||||
* If there is no unsigned field in the event this is a better fallback then 0.
|
|
||||||
* It is supposed to only be used like this: `ev.getAge() ?? ev.fallbackAge()`
|
|
||||||
*/
|
|
||||||
private fallbackAge(): number {
|
|
||||||
if (!this.getAge()) {
|
|
||||||
logger.warn(
|
|
||||||
"Age for event was not available, using `now - origin_server_ts` as a fallback. If the device clock is not correct issues might occur.",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return Math.max(Date.now() - this.getTs(), 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the age of the event when this function was called.
|
* Get the age of the event when this function was called.
|
||||||
* This is the 'age' field adjusted according to how long this client has
|
* This is the 'age' field adjusted according to how long this client has
|
||||||
@@ -1399,7 +1384,7 @@ export class MatrixEvent extends TypedEventEmitter<MatrixEventEmittedEvents, Mat
|
|||||||
this.emit(MatrixEventEvent.LocalEventIdReplaced, this);
|
this.emit(MatrixEventEvent.LocalEventIdReplaced, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.localTimestamp = Date.now() - (this.getAge() ?? this.fallbackAge());
|
this.localTimestamp = Date.now() - this.getAge()!;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user