Fix profile loader
This commit is contained in:
@ -56,7 +56,7 @@ export default class Connection {
|
||||
*/
|
||||
AddSubscription(sub) {
|
||||
let req = ["REQ", sub.Id, sub.ToObject()];
|
||||
if(sub.OrSubs.length > 0) {
|
||||
if (sub.OrSubs.length > 0) {
|
||||
req = [
|
||||
...req,
|
||||
...sub.OrSubs.map(o => o.ToObject())
|
||||
@ -71,9 +71,13 @@ export default class Connection {
|
||||
* @param {any} subId Subscription id to remove
|
||||
*/
|
||||
RemoveSubscription(subId) {
|
||||
let req = ["CLOSE", subId];
|
||||
this._SendJson(req);
|
||||
delete this.Subscriptions[subId];
|
||||
if (this.Subscriptions[subId]) {
|
||||
let req = ["CLOSE", subId];
|
||||
this._SendJson(req);
|
||||
delete this.Subscriptions[subId];
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
_SendJson(obj) {
|
||||
|
@ -60,7 +60,8 @@ export class NostrSystem {
|
||||
};
|
||||
sub.OnEnd = (c) => {
|
||||
c.RemoveSubscription(sub.Id);
|
||||
if(--counter === 0) {
|
||||
console.debug(counter);
|
||||
if (counter-- <= 0) {
|
||||
resolve(events);
|
||||
}
|
||||
};
|
||||
@ -68,6 +69,15 @@ export class NostrSystem {
|
||||
s.AddSubscription(sub);
|
||||
counter++;
|
||||
}
|
||||
|
||||
// force timeout returning current results
|
||||
setTimeout(() => {
|
||||
for (let s of Object.values(this.Sockets)) {
|
||||
s.RemoveSubscription(sub.Id);
|
||||
counter++;
|
||||
}
|
||||
resolve(events);
|
||||
}, 10_000);
|
||||
});
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user