Push multiple updates in each update event

Refactor HostUpdatesEvent, InstanceDetailsUpdatesEvent, ModUpdatesEvent,
ModPackUpdatesEvent and UserUpdatesEvent to have multiple updates of the
entities they support in each event. This is intended to make the events
capable of syncing the entire list that they represent.
This commit is contained in:
Hornwitser committed 2023-12-08 22:01:46 +01:00
1 parent f12a9926eb
commit 20330bc2c3
18 files changed
+215 -190

No files matched your search

+7 -9
View File
@@ -81,25 +81,23 @@ export class InstanceDetailsListRequest {
static Response = jsonArray(InstanceDetails);
};
export class InstanceDetailsUpdateEvent {
declare ["constructor"]: typeof InstanceDetailsUpdateEvent;
export class InstanceDetailsUpdatesEvent {
declare ["constructor"]: typeof InstanceDetailsUpdatesEvent;
static type = "event" as const;
static src = "controller" as const;
static dst = "control" as const;
static permission = "core.instance.subscribe" as const;
constructor(
public details: InstanceDetails,
public updates: InstanceDetails[],
) { }
static jsonSchema = InstanceDetails.jsonSchema;
toJSON() {
return this.details;
}
static jsonSchema = Type.Object({
"updates": Type.Array(InstanceDetails.jsonSchema),
});
static fromJSON(json: Static<typeof this.jsonSchema>) {
return new this(InstanceDetails.fromJSON(json));
return new this(json.updates.map(update => InstanceDetails.fromJSON(update)));
}
};