Something went wrong

Thank you for being patient! We're working hard on resolving the issue

Calendars - Lona Docs Log in

Calendars

Calendars connect external calendar providers (Google Calendar, Apple Calendar, etc.) to Lona via OAuth. Each connected account appears as a calendar row in your sheet with child rows for different views.

Calendar rows

A calendar row represents a connected calendar. Its children are:

TypeDescription
calendar-listList view of events
timelineAll-day events
calendar-monthMonth grid view
const calendar = sheet.row({ type: "calendar" });
console.log(calendar?.lookupKey); // e.g., ":~calendar"

CalendarClient

client.calendars manages connected calendars, their display metadata, and visibility preferences.

Initialization

// Fetch from API (typically done once at app startup)
await client.calendars.fetch(userId);

// Or initialize with pre-fetched data (tests, offline)
client.calendars.initializeWith(userId, calendarLists);

Listing calendars

// All calendar lists (grouped by auth account)
const allCalendars = client.calendars.listAll();

// Only visible calendars
const visible = client.calendars.listVisible();

// Primary auth account
const primaryAuth = client.calendars.primaryAuth();

// Primary calendar
const primary = client.calendars.primary();
const primaryId = client.calendars.primaryId();

Looking up a calendar

import { AuthScopedCalendarId } from "@tento-lona";

const acid: AuthScopedCalendarId = [authId, calendarId];
const calendar = client.calendars.find(acid);

if (calendar) {
  const [authId, display] = calendar;
  console.log(display.summary); // "Work Calendar"
}

Visibility

Calendars are visible by default. Toggle visibility to hide/show calendars in the UI:

// Check visibility
const visible = client.calendars.isVisible(acid);

// Toggle
client.calendars.setVisible(acid, false);

Visibility changes are persisted to user preferences and broadcast via the invalidation system.

Writable calendars

Get calendars the user can write to (for "move event" or "create event" UIs). Excludes a specific calendar and limits results:

const targets = client.calendars.writable(
  currentCalendarAcid, // exclude current
  5,                   // max results
);

for (const cal of targets) {
  console.log(`${cal.summary} (${cal.authId}/${cal.calendarId})`);
}

Subscribing to changes

const unsubscribe = client.calendars.onVisibilityChange(() => {
  // Re-render calendar UI
});

See also