mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2025-12-10 00:58:51 +00:00
fix some important bugs so it is actually usable.
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "nostr-tools",
|
"name": "nostr-tools",
|
||||||
"version": "0.4.4",
|
"version": "0.4.5",
|
||||||
"description": "Tools for making a Nostr client.",
|
"description": "Tools for making a Nostr client.",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|||||||
7
pool.js
7
pool.js
@@ -25,11 +25,14 @@ export function relayPool(globalPrivateKey) {
|
|||||||
])
|
])
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const activeCallback = cb
|
||||||
|
const activeFilters = filter
|
||||||
|
|
||||||
activeSubscriptions[id] = {
|
activeSubscriptions[id] = {
|
||||||
sub: ({cb = cb, filter = filter}) =>
|
sub: ({cb = activeCallback, filter = activeFilters}) =>
|
||||||
Object.entries(subControllers).map(([relayURL, sub]) => [
|
Object.entries(subControllers).map(([relayURL, sub]) => [
|
||||||
relayURL,
|
relayURL,
|
||||||
sub({cb, filter}, id)
|
sub.sub({cb, filter}, id)
|
||||||
]),
|
]),
|
||||||
addRelay: relay => {
|
addRelay: relay => {
|
||||||
subControllers[relay.url] = relay.sub({cb, filter})
|
subControllers[relay.url] = relay.sub({cb, filter})
|
||||||
|
|||||||
6
relay.js
6
relay.js
@@ -118,8 +118,12 @@ export function relayConnect(url, onNotice) {
|
|||||||
channels[channel] = cb
|
channels[channel] = cb
|
||||||
openSubs[channel] = filters
|
openSubs[channel] = filters
|
||||||
|
|
||||||
|
const activeCallback = cb
|
||||||
|
const activeFilters = filters
|
||||||
|
|
||||||
return {
|
return {
|
||||||
sub: ({cb = cb, filter = filter}) => sub({cb, filter}, channel),
|
sub: ({cb = activeCallback, filter = activeFilters}) =>
|
||||||
|
sub({cb, filter}, channel),
|
||||||
unsub: () => {
|
unsub: () => {
|
||||||
delete openSubs[channel]
|
delete openSubs[channel]
|
||||||
delete channels[channel]
|
delete channels[channel]
|
||||||
|
|||||||
Reference in New Issue
Block a user