From f2f8b6b225f14b1329ad8c2b0538dd48fcc54cf3 Mon Sep 17 00:00:00 2001 From: kieran Date: Tue, 28 May 2024 13:09:34 +0100 Subject: [PATCH] chore: ToNostrEventTag.equals --- packages/system-react/package.json | 4 ++-- packages/system/package.json | 2 +- packages/system/src/nostr-link.ts | 17 +++++++++++++++-- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/packages/system-react/package.json b/packages/system-react/package.json index 331f56b9..b2bbaabb 100644 --- a/packages/system-react/package.json +++ b/packages/system-react/package.json @@ -1,6 +1,6 @@ { "name": "@snort/system-react", - "version": "1.3.3", + "version": "1.3.5", "description": "React hooks for @snort/system", "main": "dist/index.js", "module": "src/index.ts", @@ -17,7 +17,7 @@ ], "dependencies": { "@snort/shared": "^1.0.15", - "@snort/system": "^1.3.3", + "@snort/system": "^1.3.5", "react": "^18.2.0" }, "devDependencies": { diff --git a/packages/system/package.json b/packages/system/package.json index 28d163d3..2b6b8e7a 100644 --- a/packages/system/package.json +++ b/packages/system/package.json @@ -1,6 +1,6 @@ { "name": "@snort/system", - "version": "1.3.3", + "version": "1.3.5", "description": "Snort nostr system package", "type": "module", "main": "dist/index.js", diff --git a/packages/system/src/nostr-link.ts b/packages/system/src/nostr-link.ts index e14823cd..5c5bd4b0 100644 --- a/packages/system/src/nostr-link.ts +++ b/packages/system/src/nostr-link.ts @@ -17,10 +17,16 @@ import { findTag } from "./utils"; */ export interface ToNostrEventTag { toEventTag(): Array | undefined; + equals(other: ToNostrEventTag): boolean; } export class NostrHashtagLink implements ToNostrEventTag { - constructor(readonly tag: string) {} + constructor(readonly tag: string) { } + + equals(other: ToNostrEventTag): boolean { + const otherTag = other.toEventTag(); + return otherTag?.at(0) === "t" && otherTag?.at(1) === this.tag; + } toEventTag() { return ["t", this.tag]; @@ -28,7 +34,14 @@ export class NostrHashtagLink implements ToNostrEventTag { } export class UnknownTag implements ToNostrEventTag { - constructor(readonly value: Array) {} + constructor(readonly value: Array) { } + + equals(other: ToNostrEventTag): boolean { + const otherTag = other.toEventTag(); + return otherTag?.at(0) === this.value.at(0) && + otherTag?.at(1) === this.value.at(1) + } + toEventTag(): string[] | undefined { return this.value; }