Complete buy flow

This commit is contained in:
2023-01-12 21:36:31 +00:00
parent bcdf035063
commit 192877c5d2
7 changed files with 170 additions and 27 deletions

View File

@ -70,7 +70,11 @@ export default class Connection {
for (let p of this.Pending) {
this._SendJson(p);
}
this.Pending = [];
for (let s of Object.values(this.Subscriptions)) {
this._SendSubscription(s, s.ToObject());
}
this._UpdateState();
}
@ -159,15 +163,7 @@ export default class Connection {
return;
}
let req = ["REQ", sub.Id, subObj];
if (sub.OrSubs.length > 0) {
req = [
...req,
...sub.OrSubs.map(o => o.ToObject())
];
}
sub.Started[this.Address] = new Date().getTime();
this._SendJson(req);
this._SendSubscription(sub, subObj);
this.Subscriptions[sub.Id] = sub;
}
@ -227,6 +223,18 @@ export default class Connection {
}
}
_SendSubscription(sub, subObj) {
let req = ["REQ", sub.Id, subObj];
if (sub.OrSubs.length > 0) {
req = [
...req,
...sub.OrSubs.map(o => o.ToObject())
];
}
sub.Started[this.Address] = new Date().getTime();
this._SendJson(req);
}
_SendJson(obj) {
if (this.Socket?.readyState !== WebSocket.OPEN) {
this.Pending.push(obj);