From a6707c111f4dc4fe8ac8b10b6d50aa5855a75142 Mon Sep 17 00:00:00 2001 From: kieran Date: Mon, 29 Apr 2024 13:52:07 +0100 Subject: [PATCH] chore: some notification fixes --- packages/app/.gitignore | 3 ++- .../Pages/Notifications/NotificationGroup.tsx | 1 + .../Notifications/getNotificationContext.tsx | 18 +++++++++++------- packages/system/src/sync/diff-sync.ts | 5 ++++- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/packages/app/.gitignore b/packages/app/.gitignore index e273abda..1fd5e14c 100644 --- a/packages/app/.gitignore +++ b/packages/app/.gitignore @@ -25,4 +25,5 @@ yarn-error.log* .idea dist/ -dev-dist/ \ No newline at end of file +dev-dist/ +.wrangler/ \ No newline at end of file diff --git a/packages/app/src/Pages/Notifications/NotificationGroup.tsx b/packages/app/src/Pages/Notifications/NotificationGroup.tsx index 84e3b5d3..cf8550eb 100644 --- a/packages/app/src/Pages/Notifications/NotificationGroup.tsx +++ b/packages/app/src/Pages/Notifications/NotificationGroup.tsx @@ -153,6 +153,7 @@ export function NotificationGroup({ )} )} + {window.location.search === "?debug=true" &&
{JSON.stringify(evs, undefined, 2)}
} {context && } diff --git a/packages/app/src/Pages/Notifications/getNotificationContext.tsx b/packages/app/src/Pages/Notifications/getNotificationContext.tsx index 8c1673e5..00655e7f 100644 --- a/packages/app/src/Pages/Notifications/getNotificationContext.tsx +++ b/packages/app/src/Pages/Notifications/getNotificationContext.tsx @@ -1,4 +1,4 @@ -import { EventKind, Nip10, NostrLink, TaggedNostrEvent } from "@snort/system"; +import { EventKind, Nip10, NostrEvent, NostrLink, TaggedNostrEvent } from "@snort/system"; export function getNotificationContext(ev: TaggedNostrEvent) { switch (ev.kind) { @@ -17,14 +17,18 @@ export function getNotificationContext(ev: TaggedNostrEvent) { } break; } - case EventKind.Repost: + case EventKind.Repost: { + if (ev.kind === EventKind.Repost && ev.content.startsWith("{")) { + const innerEvent = JSON.parse(ev.content) as NostrEvent; + return NostrLink.fromEvent(innerEvent); + } else { + const thread = Nip10.parseThread(ev); + return thread?.replyTo ?? thread?.root ?? thread?.mentions[0]; + } + } case EventKind.Reaction: { const thread = Nip10.parseThread(ev); - const tag = thread?.replyTo ?? thread?.root ?? thread?.mentions[0]; - if (tag) { - return tag; - } - break; + return thread?.replyTo ?? thread?.root ?? thread?.mentions[0]; } case EventKind.TextNote: { return NostrLink.fromEvent(ev); diff --git a/packages/system/src/sync/diff-sync.ts b/packages/system/src/sync/diff-sync.ts index d6e98bb8..44edb3d6 100644 --- a/packages/system/src/sync/diff-sync.ts +++ b/packages/system/src/sync/diff-sync.ts @@ -18,7 +18,10 @@ export class DiffSyncTags extends EventEmitter { #changesEncrypted: Array = []; #decryptedContent?: string; - constructor(readonly link: NostrLink, readonly contentEncrypted: boolean) { + constructor( + readonly link: NostrLink, + readonly contentEncrypted: boolean, + ) { super(); this.#sync = new SafeSync(link); this.#sync.on("change", () => {