mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-14 07:24:52 +09:00
Use -1 as the default lastResponseTime
Entites that didn't have an updatedAt time at the time of creation will default to having one set to 0. Since entities with an updatedAt time greater than lastResponseTime is expected to be returned this means that these entities would not be included when a client does its initial sync subscribing to a resource. Change the default lastResponseTime requested so that these entities are included.
This commit is contained in:
1 parent
5748f834ff
commit
0c4387769e
2 files changed
+6
-6
No files matched your search
@@ -208,7 +208,7 @@ export class SubscriptionController {
|
||||
export class EventSubscriber<T extends Event<T>, V=T> {
|
||||
_callbacks = new Array<EventSubscriberCallback<V>>();
|
||||
lastResponse: Event<T> | null = null;
|
||||
lastResponseTime = 0;
|
||||
lastResponseTime = -1;
|
||||
control?: Link;
|
||||
|
||||
constructor(
|
||||
|
||||
@@ -63,8 +63,8 @@ describe("lib/subscriptions", function() {
|
||||
assert.deepEqual(reconstructed, response);
|
||||
});
|
||||
|
||||
it("should be round trip json serialisable with a null event replay", function() {
|
||||
const response = new lib.SubscriptionResponse(null);
|
||||
it("should be round trip json serialisable with an undefined event replay", function() {
|
||||
const response = new lib.SubscriptionResponse(undefined);
|
||||
const json = JSON.stringify(response);
|
||||
assert.equal(typeof json, "string");
|
||||
const reconstructed = lib.SubscriptionResponse.fromJSON(JSON.parse(json));
|
||||
@@ -396,13 +396,13 @@ describe("lib/subscriptions", function() {
|
||||
|
||||
describe("_updateSubscription()", function() {
|
||||
it("should correctly request a subscription", async function() {
|
||||
const expected = new lib.SubscriptionRequest(RegisteredEvent.name, true);
|
||||
const expected = new lib.SubscriptionRequest(RegisteredEvent.name, true, -1);
|
||||
registeredEvent.subscribe(() => true);
|
||||
await events.once(mockControl.connector, "send");
|
||||
assertLastRequest(expected);
|
||||
});
|
||||
it("should correctly request a no subscriptions", async function() {
|
||||
const expected = new lib.SubscriptionRequest(RegisteredEvent.name, false);
|
||||
it("should correctly request no subscriptions", async function() {
|
||||
const expected = new lib.SubscriptionRequest(RegisteredEvent.name, false, -1);
|
||||
function callback() {}
|
||||
registeredEvent.subscribe(callback);
|
||||
await events.once(mockControl.connector, "send");
|
||||
|
||||
Reference in new issue
Block a user