fix: duplicate relays

This commit is contained in:
2024-02-27 17:45:35 +00:00
parent 5796892e54
commit be48c9cc37
4 changed files with 6 additions and 5 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@snort/system-react", "name": "@snort/system-react",
"version": "1.2.11", "version": "1.2.12",
"description": "React hooks for @snort/system", "description": "React hooks for @snort/system",
"main": "dist/index.js", "main": "dist/index.js",
"module": "src/index.ts", "module": "src/index.ts",
@ -17,7 +17,7 @@
], ],
"dependencies": { "dependencies": {
"@snort/shared": "^1.0.14", "@snort/shared": "^1.0.14",
"@snort/system": "^1.2.11", "@snort/system": "^1.2.12",
"react": "^18.2.0" "react": "^18.2.0"
}, },
"devDependencies": { "devDependencies": {

View File

@ -9,6 +9,7 @@
"jsx": "react-jsx", "jsx": "react-jsx",
"strict": true, "strict": true,
"declaration": true, "declaration": true,
"declarationMap": true,
"inlineSourceMap": true, "inlineSourceMap": true,
"outDir": "dist", "outDir": "dist",
"skipLibCheck": true "skipLibCheck": true

View File

@ -1,6 +1,6 @@
{ {
"name": "@snort/system", "name": "@snort/system",
"version": "1.2.11", "version": "1.2.12",
"description": "Snort nostr system package", "description": "Snort nostr system package",
"type": "module", "type": "module",
"main": "dist/index.js", "main": "dist/index.js",

View File

@ -1,4 +1,4 @@
import { SortedMap } from "@snort/shared"; import { SortedMap, dedupe } from "@snort/shared";
import { EventExt, EventType, TaggedNostrEvent } from "."; import { EventExt, EventType, TaggedNostrEvent } from ".";
import { findTag } from "./utils"; import { findTag } from "./utils";
import EventEmitter from "eventemitter3"; import EventEmitter from "eventemitter3";
@ -73,7 +73,7 @@ export class KeyedReplaceableNoteStore extends HookedNoteStore {
const existingCreated = existing?.created_at ?? 0; const existingCreated = existing?.created_at ?? 0;
if (a.created_at > existingCreated) { if (a.created_at > existingCreated) {
if (existing) { if (existing) {
a.relays.push(...existing.relays); a.relays = dedupe([...existing.relays, ...a.relays]);
} }
this.#events.set(keyOnEvent, a); this.#events.set(keyOnEvent, a);
changes.push(a); changes.push(a);