chore: some notification fixes
Some checks reported errors
continuous-integration/drone/push Build encountered an error

This commit is contained in:
kieran 2024-04-29 13:52:07 +01:00
parent b199d1a366
commit a6707c111f
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941
4 changed files with 18 additions and 9 deletions

View File

@ -25,4 +25,5 @@ yarn-error.log*
.idea
dist/
dev-dist/
dev-dist/
.wrangler/

View File

@ -153,6 +153,7 @@ export function NotificationGroup({
)}
</div>
)}
{window.location.search === "?debug=true" && <pre>{JSON.stringify(evs, undefined, 2)}</pre>}
{context && <NotificationContext link={context} />}
</div>
</>

View File

@ -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);

View File

@ -18,7 +18,10 @@ export class DiffSyncTags extends EventEmitter<SafeSyncEvents> {
#changesEncrypted: Array<TagDiff> = [];
#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", () => {