fix: s13n

This commit is contained in:
cha0s 2021-04-21 09:33:46 -05:00
parent 0042270f62
commit b62f71bb3c

View File

@ -27,7 +27,14 @@ export default (latus) => (Resource) => (
if (this._synchronized[type]?.[id]) {
const promises = [];
for (let i = 0; i < packet.data.packets.length; i++) {
promises.push(this._synchronized[type][id].acceptPacket(packet.data.packets[i]));
const update = packet.data.packets[i];
promises.push(
Promise
.resolve(this._synchronized[type][id])
.then((resource) => {
resource.acceptPacket(update);
}),
);
}
await Promise.all(promises);
}
@ -52,10 +59,12 @@ export default (latus) => (Resource) => (
this._synchronized[type] = {};
}
if (this._synchronized[type][id]) {
await this._synchronized[type][id].load(json);
await (await this._synchronized[type][id]).load(json);
}
else {
this._serializer.create(`${type}:${id}`, Resource.load(json));
const later = Resource.load(json);
this._synchronized[type][id] = later;
this._serializer.create(`${type}:${id}`, later);
await this._serializer.later(`${type}:${id}`, (resource) => {
this._synchronized[type][id] = resource;
});