Skip to content

Commit

Permalink
Make sync trigger robust to error handling to resolve #4
Browse files Browse the repository at this point in the history
  • Loading branch information
iansan5653 authored Feb 9, 2024
1 parent 87f2e0b commit 2f96358
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
18 changes: 16 additions & 2 deletions src/jobs/updateSyncTriggers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,25 @@ export function updateSyncTriggers() {

const existingTriggers = SyncTriggerController.readAll();

Logger.log("Deleting all existing sync triggers");

for (const existingTriggerTeamMember of Object.keys(existingTriggers))
if (!allTeamMembers.has(existingTriggerTeamMember))
try {
SyncTriggerController.delete(existingTriggerTeamMember);
} catch (e) {
Logger.log(`Failed to delete existing sync trigger for ${existingTriggerTeamMember}: ${e}`);
}

Logger.log(`Creating new triggers for all team members in all calendars: ${[...allTeamMembers]}`);

for (const teamMember of allTeamMembers)
try {
SyncTriggerController.create(teamMember);
} catch (e) {
Logger.log(`Failed to create new sync trigger for ${teamMember}: ${e}`);
}

for (const teamMember of allTeamMembers) SyncTriggerController.create(teamMember);
Logger.log("Finished updating sync triggers");

lock.releaseLock();
}
18 changes: 5 additions & 13 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,9 @@
"noUncheckedIndexedAccess": true,
"esModuleInterop": true,
"outDir": "build",
"lib": [
"ES2021"
],
"types": [
"google-apps-script"
]
"lib": ["ES2021"],
"types": ["google-apps-script"]
},
"include": [
"src"
],
"files": [
"src/index.ts"
]
}
"include": ["src"],
"files": ["src/index.ts"]
}

0 comments on commit 2f96358

Please sign in to comment.