Skip to content

Commit

Permalink
Preserve unchanged events in sync state
Browse files Browse the repository at this point in the history
  • Loading branch information
iansan5653 authored Feb 1, 2024
1 parent 7892ab1 commit 352cd7b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/jobs/syncCalendarForTeamMember.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export function syncCalendarForTeamMember(
const displayName = getTeamMemberDisplayName(teamMember, calendar.nameFormat);
Logger.log(`Display name for ${teamMember} is ${displayName}`);

const newSyncState = { ...TeamMemberSyncState.empty(), syncToken: nextSyncToken };
const newSyncState = { eventIds: { ...syncState.eventIds }, syncToken: nextSyncToken };

const counts = { deleted: 0, modified: 0, created: 0 };

Expand All @@ -173,6 +173,7 @@ export function syncCalendarForTeamMember(
if ((sourceEvent.status === "cancelled" || !sourceEventIsLongEnough) && teamCalendarEventId) {
counts.deleted++;
deleteEvent(calendar.googleCalendarId, teamCalendarEventId);
delete newSyncState.eventIds[sourceEvent.id];
} else if (teamCalendarEventId) {
counts.modified++;
updateEvent(displayName, sourceEvent, calendar.googleCalendarId, teamCalendarEventId);
Expand Down

0 comments on commit 352cd7b

Please sign in to comment.