Skip to content

Commit

Permalink
feat: implement successful sync icon (#76)
Browse files Browse the repository at this point in the history
* feat: implement successful sync icon

* fix: make icon match more restrictive
  • Loading branch information
lyind committed Jun 23, 2023
1 parent 963e3c2 commit 2087492
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions sync-timeoffs/SyncTimeOffs.js
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,9 @@ async function syncActionUpdateTimeOff_(personio, calendar, primaryEmail, event,
const createdTimeOff = await createPersonioTimeOff_(personio, updatedTimeOff);
setEventPrivateProperty_(event, 'timeOffId', createdTimeOff.id);
updateEventPersonioDeepLink_(event, createdTimeOff);
if (!/ ?⇵$/.test(event.summary)) {
event.summary += ' ⇵';
}
await calendar.update('primary', event.id, event);
Logger.log('Updated TimeOff "%s" at %s for user %s', createdTimeOff.typeName, String(createdTimeOff.startAt), primaryEmail);
return true;
Expand Down Expand Up @@ -759,6 +762,9 @@ async function syncActionInsertTimeOff_(personio, calendar, primaryEmail, event,
const createdTimeOff = await createPersonioTimeOff_(personio, newTimeOff);
setEventPrivateProperty_(event, 'timeOffId', createdTimeOff.id);
updateEventPersonioDeepLink_(event, createdTimeOff);
if (!/ ?⇵$/.test(event.summary)) {
event.summary += ' ⇵';
}
await calendar.update('primary', event.id, event);
Logger.log('Inserted TimeOff "%s" at %s for user %s: %s', createdTimeOff.typeName, String(createdTimeOff.startAt), primaryEmail, createdTimeOff.comment);
return true;
Expand Down Expand Up @@ -916,7 +922,7 @@ function convertOutOfOfficeToTimeOff_(timeOffTypeConfig, employee, event, existi
endAt: endAt,
typeId: timeOffType.attributes.id,
typeName: timeOffType.attributes.name,
comment: event.summary.replace(' [synced]', ''),
comment: event.summary.replace(/ ?⇵$/, ''),
updatedAt: new Date(event.updated),
employeeId: employee.attributes.id.value,
email: employee.attributes.email.value,
Expand Down Expand Up @@ -985,7 +991,7 @@ function createEventFromTimeOff_(timeOffTypeConfig, timeOff) {
timeOffId: timeOff.id
}
},
summary: `${timeOff.comment} [synced]`
summary: `${timeOff.comment} `
};

// if we can't guess the corresponding time-off-type, prefix the event summary with its name
Expand Down

0 comments on commit 2087492

Please sign in to comment.