mirror of
https://github.com/dergigi/boris.git
synced 2026-01-23 16:54:33 +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.
36 lines
1.7 KiB
JavaScript
36 lines
1.7 KiB
JavaScript
import { getAddressPointerForEvent, getEventPointerForEvent } from "applesauce-core/helpers";
|
|
import { kinds } from "nostr-tools";
|
|
import { isAddressableKind } from "nostr-tools/kinds";
|
|
import { ensureAddressPointerTag, ensureEventPointerTag, ensureKTag, ensureProfilePointerTag, } from "../helpers/common-tags.js";
|
|
import { setContent } from "./content.js";
|
|
// TODO: some of these operations should be refactored to use "modifyPublicTags"
|
|
/** Includes NIP-18 repost tags */
|
|
export function setShareTags(event) {
|
|
return async (draft, ctx) => {
|
|
let tags = Array.from(draft.tags);
|
|
const hint = await ctx.getEventRelayHint?.(event.id);
|
|
// add "e" tag
|
|
tags = ensureEventPointerTag(tags, getEventPointerForEvent(event, hint ? [hint] : undefined));
|
|
// add "a" tag
|
|
if (isAddressableKind(event.kind)) {
|
|
tags = ensureAddressPointerTag(tags, getAddressPointerForEvent(event, hint ? [hint] : undefined));
|
|
}
|
|
// add "p" tag for notify
|
|
const pubkeyHint = await ctx.getPubkeyRelayHint?.(event.pubkey);
|
|
tags = ensureProfilePointerTag(tags, { pubkey: event.pubkey, relays: pubkeyHint ? [pubkeyHint] : undefined });
|
|
// add "k" tag
|
|
tags = ensureKTag(tags, event.kind);
|
|
return { ...draft, tags };
|
|
};
|
|
}
|
|
/** Sets the NIP-18 repost kind based on the kind of event being shared */
|
|
export function setShareKind(event) {
|
|
return (draft) => {
|
|
return { ...draft, kind: event.kind === kinds.ShortTextNote ? kinds.Repost : kinds.GenericRepost };
|
|
};
|
|
}
|
|
/** Sets the content of the event to a JSON string of the shared event */
|
|
export function embedSharedEvent(event) {
|
|
return setContent(JSON.stringify(event));
|
|
}
|