Files
boris/node_modules/applesauce-factory/dist/operations/poll.js
Gigi 5d53a827e0 feat: initialize markr nostr bookmark client
- 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.
2025-10-02 07:17:07 +02:00

42 lines
1.7 KiB
JavaScript

import { includeSingletonTag, modifyPublicTags } from "./tags.js";
/** Sets the content (poll question/label) for a poll event */
export function setQuestion(question) {
return (draft) => ({ ...draft, content: question });
}
/** Adds an option to a poll with an option ID and label */
export function addOption(optionId, label) {
return modifyPublicTags((tags) => [...tags, ["option", optionId, label]]);
}
/** Sets multiple poll options at once, replacing any existing option tags */
export function setOptions(options) {
return modifyPublicTags((tags) => {
// Remove existing option tags
const filteredTags = tags.filter((tag) => tag[0] !== "option");
// Add new option tags
const optionTags = options.map((option) => ["option", option.id, option.label]);
return [...filteredTags, ...optionTags];
});
}
/** Sets the poll type (singlechoice or multiplechoice) */
export function setType(pollType) {
return includeSingletonTag(["polltype", pollType]);
}
/** Sets the poll expiration timestamp */
export function setEndsAt(timestamp) {
return includeSingletonTag(["endsAt", timestamp.toString()]);
}
/** Adds a relay URL where poll responses should be published */
export function addRelay(relayUrl) {
return modifyPublicTags((tags) => [...tags, ["relay", relayUrl]]);
}
/** Sets multiple relay URLs at once, replacing any existing relay tags */
export function setRelays(relayUrls) {
return modifyPublicTags((tags) => {
// Remove existing relay tags
const filteredTags = tags.filter((tag) => tag[0] !== "relay");
// Add new relay tags
const relayTags = relayUrls.map((url) => ["relay", url]);
return [...filteredTags, ...relayTags];
});
}