Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
BlowaterNostr committed Apr 8, 2024
1 parent 26aae84 commit a4f9985
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
6 changes: 5 additions & 1 deletion test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ import {
SingleRelayConnection,
SubscriptionStream,
} from "./_libs.ts";
import { limit } from "https://raw.githubusercontent.com/BlowaterNostr/nostr.ts/main/relay-single-test.ts";
import {
limit,
no_event,
} from "https://raw.githubusercontent.com/BlowaterNostr/nostr.ts/main/relay-single-test.ts";

const test_kv = async () => {
try {
Expand Down Expand Up @@ -139,6 +142,7 @@ Deno.test("main", async (t) => {

await t.step("nip1", async () => {
await limit(relay.url)();
await no_event(relay.url)();
});

await client.close();
Expand Down
24 changes: 12 additions & 12 deletions ws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,17 @@ async function handle_filter(args: {
event_candidates.set(event.id, event);
}
}
if (filter.authors) {
if (event_candidates.size > 0) {
console.log("event_candidates", event_candidates);
} else {
const events = args.get_events_by_authors(new Set(filter.authors));
for await (const event of events) {
console.log(event);
event_candidates.set(event.id, event);
}
}
}
if (filter.kinds) {
if (event_candidates.size > 0) {
const keys = Array.from(event_candidates.keys());
Expand All @@ -237,25 +248,14 @@ async function handle_filter(args: {
}
event_candidates.delete(key);
}
} else {
} else if (!filter.authors) {
const events = get_events_by_kinds(new Set(filter.kinds));
for await (const event of events) {
console.log(event);
event_candidates.set(event.id, event);
}
}
}
if (filter.authors) {
if (event_candidates.size > 0) {
console.log("event_candidates", event_candidates);
} else {
const events = args.get_events_by_authors(new Set(filter.authors));
for await (const event of events) {
console.log(event);
event_candidates.set(event.id, event);
}
}
}
if (filter.limit) {
for await (const event of args.get_events_by_filter(filter)) {
event_candidates.set(event.id, event);
Expand Down

0 comments on commit a4f9985

Please sign in to comment.