mirror of
https://github.com/dergigi/boris.git
synced 2026-01-09 01:44:24 +01:00
- Add project structure with TypeScript, React, and Vite - Implement nostr authentication using browser extension (NIP-07) - Add NIP-51 compliant bookmark fetching and display - Create minimal UI with login and bookmark components - Integrate applesauce-core and applesauce-react libraries - Add responsive styling with dark/light mode support - Include comprehensive README with setup instructions This is a minimal MVP for a nostr bookmark client that allows users to view their bookmarks according to NIP-51 specification.
42 lines
1.7 KiB
JavaScript
42 lines
1.7 KiB
JavaScript
import { getNip10References, isPTag } from "applesauce-core/helpers";
|
|
import { kinds } from "nostr-tools";
|
|
import { ensureMarkedEventPointerTag, ensureProfilePointerTag } from "../helpers/common-tags.js";
|
|
/**
|
|
* Includes NIP-10 reply tags
|
|
* @throws {Error} if the parent is not a short text note
|
|
*/
|
|
export function setThreadParent(parent) {
|
|
if (parent.kind !== kinds.ShortTextNote)
|
|
throw new Error("Parent must be a short text note");
|
|
return async (draft, ctx) => {
|
|
let tags = Array.from(draft.tags);
|
|
const pointer = { id: parent.id, author: parent.pubkey, kind: parent.kind };
|
|
if (ctx.getEventRelayHint) {
|
|
const hint = await ctx.getEventRelayHint(parent.id);
|
|
if (hint)
|
|
pointer.relays = [hint];
|
|
}
|
|
const refs = getNip10References(parent);
|
|
const root = refs.root?.e ?? pointer;
|
|
const reply = pointer;
|
|
tags = ensureMarkedEventPointerTag(tags, root, "root");
|
|
tags = ensureMarkedEventPointerTag(tags, reply, "reply");
|
|
return { ...draft, tags };
|
|
};
|
|
}
|
|
/** Copies "p" tags from parent event and adds new pubkeys */
|
|
export function includeNofityTags(parent) {
|
|
return async (draft, ctx) => {
|
|
let tags = Array.from(draft.tags);
|
|
// copy "p" tags from parent event that are not mentions
|
|
for (const tag of parent.tags) {
|
|
if (isPTag(tag) && tag[3] !== "mention")
|
|
tags.push(tag);
|
|
}
|
|
// add new "p" tag
|
|
const hint = await ctx.getPubkeyRelayHint?.(parent.pubkey);
|
|
tags = ensureProfilePointerTag(tags, { pubkey: parent.pubkey, relays: hint ? [hint] : undefined });
|
|
return { ...draft, tags };
|
|
};
|
|
}
|