From b5a4617037a3df80eeb663f4b70b7d85be4181a3 Mon Sep 17 00:00:00 2001 From: SinhSinh An Date: Sat, 28 Mar 2026 22:36:01 -0500 Subject: [PATCH] fix: allow editing past GCal events after unsync (#643) When keepPastEvents is true during disableSync, set google=false on past events so they become editable. Also add 'google' to the conflict update columns in syncCalendar so resyncing reclaims those events. --- src/server/api/routers/event.ts | 20 ++++++++++++++++++++ src/utils/calendar.ts | 1 + 2 files changed, 21 insertions(+) diff --git a/src/server/api/routers/event.ts b/src/server/api/routers/event.ts index 81008c84..143248b4 100644 --- a/src/server/api/routers/event.ts +++ b/src/server/api/routers/event.ts @@ -604,6 +604,26 @@ export const eventRouter = createTRPCRouter({ ), ); + // Mark kept past events as non-google so they become editable + if (input.keepPastEvents) { + await ctx.db + .update(events) + .set({ google: false }) + .where( + and( + eq(events.clubId, input.clubId), + eq(events.google, true), + lte(events.startTime, new Date()), + clubRecord.calendarId + ? or( + eq(events.calendarId, clubRecord.calendarId), + isNull(events.calendarId), + ) + : undefined, + ), + ); + } + // remove google calendar info from the club await ctx.db .update(club) diff --git a/src/utils/calendar.ts b/src/utils/calendar.ts index 711e54b0..6a39755b 100644 --- a/src/utils/calendar.ts +++ b/src/utils/calendar.ts @@ -159,6 +159,7 @@ export async function syncCalendar( 'createdAt', 'updatedAt', 'calendarId', + 'google', ]), }); }