Skip to content

Commit c52b35f

Browse files
committed
use set for storing calendar ids for sync (#2507)
1 parent 9ff033b commit c52b35f

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

apps/desktop/src/services/apple-calendar/ctx.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ export interface Ctx {
77
userId: string;
88
from: Date;
99
to: Date;
10-
calendarIds: string[];
10+
calendarIds: Set<string>;
1111
}
1212

1313
export function createCtx(store: Store, queries: Queries<Schemas>): Ctx | null {
1414
const resultTable = queries.getResultTable(QUERIES.enabledAppleCalendars);
1515

16-
const calendarIds = Object.keys(resultTable);
16+
const calendarIds = new Set(Object.keys(resultTable));
1717

18-
if (calendarIds.length === 0) {
18+
if (calendarIds.size === 0) {
1919
return null;
2020
}
2121

apps/desktop/src/services/apple-calendar/fetch/existing.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { Ctx } from "../ctx";
22
import type { ExistingEvent } from "./types";
33

44
export function fetchExistingEvents(ctx: Ctx): Array<ExistingEvent> {
5-
const enabledCalendarIds = new Set(ctx.calendarIds);
5+
const enabledCalendarIds = ctx.calendarIds;
66
const events: Array<ExistingEvent> = [];
77

88
ctx.store.forEachRow("events", (rowId, _forEachCell) => {

apps/desktop/src/services/apple-calendar/fetch/incoming.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export async function fetchIncomingEvents(
1010
ctx: Ctx,
1111
): Promise<Array<IncomingEvent>> {
1212
const results = await Promise.all(
13-
ctx.calendarIds.map(async (calendarId) => {
13+
Array.from(ctx.calendarIds).map(async (calendarId) => {
1414
const result = await appleCalendarCommands.listEvents({
1515
calendar_tracking_id: calendarId,
1616
from: ctx.from.toISOString(),

0 commit comments

Comments
 (0)