Files
boris/node_modules/applesauce-actions/dist/actions/calendar.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

26 lines
1.3 KiB
JavaScript

import { DATE_BASED_CALENDAR_EVENT_KIND, TIME_BASED_CALENDAR_EVENT_KIND } from "applesauce-core/helpers/calendar-event";
import { Calendar } from "applesauce-factory/operations";
import { kinds } from "nostr-tools";
/** Adds a calendar event to a calendar */
export function AddEventToCalendar(calendar, event) {
if (calendar.kind !== kinds.Calendar)
throw new Error("Calendar is not a calendar event");
if (event.kind !== DATE_BASED_CALENDAR_EVENT_KIND && event.kind !== TIME_BASED_CALENDAR_EVENT_KIND)
throw new Error("Event is not a calendar event");
return async function* ({ factory }) {
const draft = await factory.modify(calendar, Calendar.addEvent(event));
return await factory.sign(draft);
};
}
/** Removes a calendar event from a calendar */
export function RemoveEventFromCalendar(calendar, event) {
if (calendar.kind !== kinds.Calendar)
throw new Error("Calendar is not a calendar event");
if (event.kind !== DATE_BASED_CALENDAR_EVENT_KIND && event.kind !== TIME_BASED_CALENDAR_EVENT_KIND)
throw new Error("Event is not a calendar event");
return async function* ({ factory }) {
const draft = await factory.modify(calendar, Calendar.removeEvent(event));
return await factory.sign(draft);
};
}