refactor: cache since, dont dedupe by host

This commit is contained in:
2023-08-01 07:58:12 +02:00
parent 5026f6a008
commit 58c55f17b6
4 changed files with 32 additions and 57 deletions

View File

@ -94,22 +94,3 @@ export async function openFile(): Promise<File | undefined> {
export function getTagValues(tags: Array<string[]>, tag: string) {
return tags.filter((t) => t.at(0) === tag).map((t) => t.at(1));
}
export function dedupeByHost(events: Array<NostrEvent>) {
const { result } = events.reduce(
({ result, seen }, ev) => {
const host = getHost(ev);
if (seen.has(host)) {
return { result, seen };
}
result.push(ev);
seen.add(host);
return { result, seen };
},
{
result: [],
seen: new Set(),
},
);
return result;
}