mirror of
https://github.com/dergigi/boris.git
synced 2026-01-07 00:44:52 +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.
80 lines
3.6 KiB
JavaScript
80 lines
3.6 KiB
JavaScript
import { addEventTag, addNameValueTag, addPubkeyTag, removeEventTag, removeNameValueTag, removePubkeyTag, } from "applesauce-factory/operations/tag";
|
|
import { kinds } from "nostr-tools";
|
|
function ensureMuteList(events, self) {
|
|
const mute = events.getReplaceable(kinds.Mutelist, self);
|
|
if (!mute)
|
|
throw new Error("No mute list found");
|
|
return mute;
|
|
}
|
|
/** An action that adds a pubkey to the mute list */
|
|
export function MuteUser(pubkey, hidden = false) {
|
|
return async function* ({ events, factory, self }) {
|
|
const mute = ensureMuteList(events, self);
|
|
const operation = addPubkeyTag(pubkey);
|
|
const draft = await factory.modifyTags(mute, hidden ? { hidden: operation } : operation);
|
|
yield await factory.sign(draft);
|
|
};
|
|
}
|
|
/** Removes a pubkey from the mute list */
|
|
export function UnmuteUser(pubkey, hidden = false) {
|
|
return async function* ({ events, factory, self }) {
|
|
const mute = ensureMuteList(events, self);
|
|
const draft = await factory.modifyTags(mute, hidden ? { hidden: removePubkeyTag(pubkey) } : removePubkeyTag(pubkey));
|
|
yield await factory.sign(draft);
|
|
};
|
|
}
|
|
/** Add a thread to the mute list */
|
|
export function MuteThread(thread, hidden = false) {
|
|
return async function* ({ events, factory, self }) {
|
|
const mute = ensureMuteList(events, self);
|
|
const operation = addEventTag(thread);
|
|
const draft = await factory.modifyTags(mute, hidden ? { hidden: operation } : operation);
|
|
yield await factory.sign(draft);
|
|
};
|
|
}
|
|
/** Removes a thread from the mute list */
|
|
export function UnmuteThread(thread, hidden = false) {
|
|
return async function* ({ events, factory, self }) {
|
|
const mute = ensureMuteList(events, self);
|
|
const operation = removeEventTag(thread);
|
|
const draft = await factory.modifyTags(mute, hidden ? { hidden: operation } : operation);
|
|
yield await factory.sign(draft);
|
|
};
|
|
}
|
|
/** Add a word to the mute list */
|
|
export function MuteWord(word, hidden = false) {
|
|
return async function* ({ events, factory, self }) {
|
|
const mute = ensureMuteList(events, self);
|
|
const operation = addNameValueTag(["word", word.toLocaleLowerCase()], true);
|
|
const draft = await factory.modifyTags(mute, hidden ? { hidden: operation } : operation);
|
|
yield await factory.sign(draft);
|
|
};
|
|
}
|
|
/** Removes a word from the mute list */
|
|
export function UnmuteWord(word, hidden = false) {
|
|
return async function* ({ events, factory, self }) {
|
|
const mute = ensureMuteList(events, self);
|
|
const operation = removeNameValueTag(["word", word.toLocaleLowerCase()]);
|
|
const draft = await factory.modifyTags(mute, hidden ? { hidden: operation } : operation);
|
|
yield await factory.sign(draft);
|
|
};
|
|
}
|
|
/** Add a hashtag to the mute list */
|
|
export function MuteHashtag(hashtag, hidden = false) {
|
|
return async function* ({ events, factory, self }) {
|
|
const mute = ensureMuteList(events, self);
|
|
const operation = addNameValueTag(["t", hashtag.toLocaleLowerCase()], true);
|
|
const draft = await factory.modifyTags(mute, hidden ? { hidden: operation } : operation);
|
|
yield await factory.sign(draft);
|
|
};
|
|
}
|
|
/** Removes a hashtag from the mute list */
|
|
export function UnmuteHashtag(hashtag, hidden = false) {
|
|
return async function* ({ events, factory, self }) {
|
|
const mute = ensureMuteList(events, self);
|
|
const operation = removeNameValueTag(["t", hashtag.toLocaleLowerCase()]);
|
|
const draft = await factory.modifyTags(mute, hidden ? { hidden: operation } : operation);
|
|
yield await factory.sign(draft);
|
|
};
|
|
}
|