Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions apps/desktop/src/calendar/queries.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@ describe("calendar SQLite queries", () => {
JSON.stringify([{ name: "Alice", email: "alice@example.com" }]),
),
).toEqual([{ name: "Alice", email: "alice@example.com" }]);
expect(
parseEventParticipants(
JSON.stringify([
null,
"Alice",
{ name: 42 },
{ name: "Bob", unexpected: true },
]),
),
).toEqual([{ name: "Bob" }]);
expect(parseEventParticipants("not-json")).toEqual([]);
expect(parseEventParticipants("{}")).toEqual([]);
});
Expand Down
71 changes: 61 additions & 10 deletions apps/desktop/src/calendar/queries.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useMemo } from "react";

import type { EventParticipant } from "@anlg/store";
import { eventParticipantSchema, type EventParticipant } from "@anlg/store";

import { executeTransaction, liveQueryClient, useLiveQuery } from "~/db";
import { enqueueDatabaseWrite } from "~/db/write-queue";
Expand Down Expand Up @@ -35,7 +35,16 @@ type CalendarSqlRow = {
created_at: string;
};

type EventParticipantsSqlRow = { participants_json: string };
type SessionCalendarEventSqlRow = {
title: string;
started_at: string;
ended_at: string;
is_all_day: boolean | number;
location: string;
meeting_link: string;
description: string;
participants_json: string;
};

type CalendarEventStartSqlRow = { started_at: string };

Expand Down Expand Up @@ -82,6 +91,14 @@ export type NearbyCalendarEvent = {
participantNames: string[];
};

export type SessionCalendarEvent = Omit<
SessionCalendarEventSqlRow,
"is_all_day" | "participants_json"
> & {
is_all_day: boolean;
participants: EventParticipant[];
};

export type CalendarRow = Omit<CalendarSqlRow, "enabled"> & {
enabled: boolean;
};
Expand Down Expand Up @@ -418,12 +435,29 @@ export async function getNearbyCalendarEvents(
export function useSessionEventParticipants(
sessionId: string,
): EventParticipant[] {
const { data = EMPTY_EVENT_PARTICIPANTS } = useLiveQuery<
EventParticipantsSqlRow,
EventParticipant[]
return (
useSessionCalendarEvent(sessionId)?.participants ?? EMPTY_EVENT_PARTICIPANTS
);
}

export function useSessionCalendarEvent(
sessionId: string,
{ enabled = true }: { enabled?: boolean } = {},
): SessionCalendarEvent | null {
const { data = null } = useLiveQuery<
SessionCalendarEventSqlRow,
SessionCalendarEvent | null
>({
sql: `
SELECT event.participants_json
SELECT
event.title,
event.started_at,
event.ended_at,
event.is_all_day,
event.location,
event.meeting_link,
event.description,
event.participants_json
FROM sessions AS session
JOIN events AS event
ON event.deleted_at IS NULL
Expand All @@ -447,10 +481,24 @@ export function useSessionEventParticipants(
LIMIT 1
`,
params: [sessionId],
enabled: Boolean(sessionId),
mapRows: (rows) => parseEventParticipants(rows[0]?.participants_json),
enabled: enabled && Boolean(sessionId),
mapRows: (rows) => {
const row = rows[0];
return row
? {
title: row.title,
started_at: row.started_at,
ended_at: row.ended_at,
is_all_day: Boolean(row.is_all_day),
location: row.location,
meeting_link: row.meeting_link,
description: row.description,
participants: parseEventParticipants(row.participants_json),
}
: null;
},
});
return sessionId ? data : EMPTY_EVENT_PARTICIPANTS;
return sessionId && enabled ? data : null;
}

export function mapTimelineEventRows(
Expand Down Expand Up @@ -486,7 +534,10 @@ export function parseEventParticipants(
try {
const parsed = JSON.parse(value);
return Array.isArray(parsed)
? (parsed as EventParticipant[])
? parsed.flatMap((participant) => {
const result = eventParticipantSchema.safeParse(participant);
return result.success ? [result.data] : [];
})
: EMPTY_EVENT_PARTICIPANTS;
} catch {
return EMPTY_EVENT_PARTICIPANTS;
Expand Down
12 changes: 12 additions & 0 deletions apps/desktop/src/i18n/locales/af/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -2308,6 +2308,10 @@ msgstr ""
msgid "Last import: {0} added, {1} unchanged"
msgstr ""

#: src/session/components/note-input/pre-meeting-brief.tsx
msgid "Last meeting"
msgstr ""

#. placeholder {0}: lastRun.detail
#: src/settings/automations/starter-config.tsx
msgid "Last run {relative}: {0}"
Expand Down Expand Up @@ -2816,6 +2820,10 @@ msgstr ""
msgid "No people in this organization"
msgstr ""

#: src/session/components/note-input/pre-meeting-brief.tsx
msgid "No previous meeting summary is available. Calendar details are shown above."
msgstr ""

#: src/settings/ai/llm/configure.tsx
#: src/settings/ai/stt/configure.tsx
msgid "No providers found."
Expand Down Expand Up @@ -3183,6 +3191,10 @@ msgstr ""
msgid "Post to a channel"
msgstr ""

#: src/session/components/note-input/pre-meeting-brief.tsx
msgid "Pre-meeting brief"
msgstr ""

#: src/settings/general/notification.tsx
msgid "Prepare for events with a 5-minute reminder."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/i18n/locales/af/messages.ts

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions apps/desktop/src/i18n/locales/am/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -2308,6 +2308,10 @@ msgstr ""
msgid "Last import: {0} added, {1} unchanged"
msgstr ""

#: src/session/components/note-input/pre-meeting-brief.tsx
msgid "Last meeting"
msgstr ""

#. placeholder {0}: lastRun.detail
#: src/settings/automations/starter-config.tsx
msgid "Last run {relative}: {0}"
Expand Down Expand Up @@ -2816,6 +2820,10 @@ msgstr ""
msgid "No people in this organization"
msgstr ""

#: src/session/components/note-input/pre-meeting-brief.tsx
msgid "No previous meeting summary is available. Calendar details are shown above."
msgstr ""

#: src/settings/ai/llm/configure.tsx
#: src/settings/ai/stt/configure.tsx
msgid "No providers found."
Expand Down Expand Up @@ -3183,6 +3191,10 @@ msgstr ""
msgid "Post to a channel"
msgstr ""

#: src/session/components/note-input/pre-meeting-brief.tsx
msgid "Pre-meeting brief"
msgstr ""

#: src/settings/general/notification.tsx
msgid "Prepare for events with a 5-minute reminder."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/i18n/locales/am/messages.ts

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions apps/desktop/src/i18n/locales/ar/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -2308,6 +2308,10 @@ msgstr ""
msgid "Last import: {0} added, {1} unchanged"
msgstr ""

#: src/session/components/note-input/pre-meeting-brief.tsx
msgid "Last meeting"
msgstr ""

#. placeholder {0}: lastRun.detail
#: src/settings/automations/starter-config.tsx
msgid "Last run {relative}: {0}"
Expand Down Expand Up @@ -2816,6 +2820,10 @@ msgstr ""
msgid "No people in this organization"
msgstr ""

#: src/session/components/note-input/pre-meeting-brief.tsx
msgid "No previous meeting summary is available. Calendar details are shown above."
msgstr ""

#: src/settings/ai/llm/configure.tsx
#: src/settings/ai/stt/configure.tsx
msgid "No providers found."
Expand Down Expand Up @@ -3183,6 +3191,10 @@ msgstr ""
msgid "Post to a channel"
msgstr ""

#: src/session/components/note-input/pre-meeting-brief.tsx
msgid "Pre-meeting brief"
msgstr ""

#: src/settings/general/notification.tsx
msgid "Prepare for events with a 5-minute reminder."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/i18n/locales/ar/messages.ts

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions apps/desktop/src/i18n/locales/as/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -2308,6 +2308,10 @@ msgstr ""
msgid "Last import: {0} added, {1} unchanged"
msgstr ""

#: src/session/components/note-input/pre-meeting-brief.tsx
msgid "Last meeting"
msgstr ""

#. placeholder {0}: lastRun.detail
#: src/settings/automations/starter-config.tsx
msgid "Last run {relative}: {0}"
Expand Down Expand Up @@ -2816,6 +2820,10 @@ msgstr ""
msgid "No people in this organization"
msgstr ""

#: src/session/components/note-input/pre-meeting-brief.tsx
msgid "No previous meeting summary is available. Calendar details are shown above."
msgstr ""

#: src/settings/ai/llm/configure.tsx
#: src/settings/ai/stt/configure.tsx
msgid "No providers found."
Expand Down Expand Up @@ -3183,6 +3191,10 @@ msgstr ""
msgid "Post to a channel"
msgstr ""

#: src/session/components/note-input/pre-meeting-brief.tsx
msgid "Pre-meeting brief"
msgstr ""

#: src/settings/general/notification.tsx
msgid "Prepare for events with a 5-minute reminder."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/i18n/locales/as/messages.ts

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions apps/desktop/src/i18n/locales/az/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -2308,6 +2308,10 @@ msgstr ""
msgid "Last import: {0} added, {1} unchanged"
msgstr ""

#: src/session/components/note-input/pre-meeting-brief.tsx
msgid "Last meeting"
msgstr ""

#. placeholder {0}: lastRun.detail
#: src/settings/automations/starter-config.tsx
msgid "Last run {relative}: {0}"
Expand Down Expand Up @@ -2816,6 +2820,10 @@ msgstr ""
msgid "No people in this organization"
msgstr ""

#: src/session/components/note-input/pre-meeting-brief.tsx
msgid "No previous meeting summary is available. Calendar details are shown above."
msgstr ""

#: src/settings/ai/llm/configure.tsx
#: src/settings/ai/stt/configure.tsx
msgid "No providers found."
Expand Down Expand Up @@ -3183,6 +3191,10 @@ msgstr ""
msgid "Post to a channel"
msgstr ""

#: src/session/components/note-input/pre-meeting-brief.tsx
msgid "Pre-meeting brief"
msgstr ""

#: src/settings/general/notification.tsx
msgid "Prepare for events with a 5-minute reminder."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/i18n/locales/az/messages.ts

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions apps/desktop/src/i18n/locales/ba/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -2308,6 +2308,10 @@ msgstr ""
msgid "Last import: {0} added, {1} unchanged"
msgstr ""

#: src/session/components/note-input/pre-meeting-brief.tsx
msgid "Last meeting"
msgstr ""

#. placeholder {0}: lastRun.detail
#: src/settings/automations/starter-config.tsx
msgid "Last run {relative}: {0}"
Expand Down Expand Up @@ -2816,6 +2820,10 @@ msgstr ""
msgid "No people in this organization"
msgstr ""

#: src/session/components/note-input/pre-meeting-brief.tsx
msgid "No previous meeting summary is available. Calendar details are shown above."
msgstr ""

#: src/settings/ai/llm/configure.tsx
#: src/settings/ai/stt/configure.tsx
msgid "No providers found."
Expand Down Expand Up @@ -3183,6 +3191,10 @@ msgstr ""
msgid "Post to a channel"
msgstr ""

#: src/session/components/note-input/pre-meeting-brief.tsx
msgid "Pre-meeting brief"
msgstr ""

#: src/settings/general/notification.tsx
msgid "Prepare for events with a 5-minute reminder."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/i18n/locales/ba/messages.ts

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions apps/desktop/src/i18n/locales/be/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -2308,6 +2308,10 @@ msgstr ""
msgid "Last import: {0} added, {1} unchanged"
msgstr ""

#: src/session/components/note-input/pre-meeting-brief.tsx
msgid "Last meeting"
msgstr ""

#. placeholder {0}: lastRun.detail
#: src/settings/automations/starter-config.tsx
msgid "Last run {relative}: {0}"
Expand Down Expand Up @@ -2816,6 +2820,10 @@ msgstr ""
msgid "No people in this organization"
msgstr ""

#: src/session/components/note-input/pre-meeting-brief.tsx
msgid "No previous meeting summary is available. Calendar details are shown above."
msgstr ""

#: src/settings/ai/llm/configure.tsx
#: src/settings/ai/stt/configure.tsx
msgid "No providers found."
Expand Down Expand Up @@ -3183,6 +3191,10 @@ msgstr ""
msgid "Post to a channel"
msgstr ""

#: src/session/components/note-input/pre-meeting-brief.tsx
msgid "Pre-meeting brief"
msgstr ""

#: src/settings/general/notification.tsx
msgid "Prepare for events with a 5-minute reminder."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/i18n/locales/be/messages.ts

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions apps/desktop/src/i18n/locales/bg/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -2308,6 +2308,10 @@ msgstr ""
msgid "Last import: {0} added, {1} unchanged"
msgstr ""

#: src/session/components/note-input/pre-meeting-brief.tsx
msgid "Last meeting"
msgstr ""

#. placeholder {0}: lastRun.detail
#: src/settings/automations/starter-config.tsx
msgid "Last run {relative}: {0}"
Expand Down Expand Up @@ -2816,6 +2820,10 @@ msgstr ""
msgid "No people in this organization"
msgstr ""

#: src/session/components/note-input/pre-meeting-brief.tsx
msgid "No previous meeting summary is available. Calendar details are shown above."
msgstr ""

#: src/settings/ai/llm/configure.tsx
#: src/settings/ai/stt/configure.tsx
msgid "No providers found."
Expand Down Expand Up @@ -3183,6 +3191,10 @@ msgstr ""
msgid "Post to a channel"
msgstr ""

#: src/session/components/note-input/pre-meeting-brief.tsx
msgid "Pre-meeting brief"
msgstr ""

#: src/settings/general/notification.tsx
msgid "Prepare for events with a 5-minute reminder."
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/i18n/locales/bg/messages.ts

Large diffs are not rendered by default.

Loading
Loading