Skip to content

Commit

Permalink
fix: Trigger missing time value handler
Browse files Browse the repository at this point in the history
Signed-off-by: John <[email protected]>
  • Loading branch information
bxb100 committed Nov 12, 2021
1 parent 016ca7d commit ede4efe
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/newtab/pages/workflows/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,21 @@ function updateWorkflow(data) {
data,
});
}
function convertToTimestamp(date, hourMinutes) {
let timestamp = Date.now() + 60000;
if (date) {
const dateObj = new Date(date);
if (hourMinutes) {
const arr = hourMinutes.split(':');
dateObj.setHours(arr[0]);
dateObj.setMinutes(arr[1]);
}
timestamp = dateObj.getTime();
}
return timestamp;
}
async function handleWorkflowTrigger({ data }) {
try {
const workflowAlarm = await browser.alarms.get(workflowId);
Expand Down Expand Up @@ -227,7 +242,7 @@ async function handleWorkflowTrigger({ data }) {
if (data.type === 'date') {
alarmInfo = {
when: data.date ? new Date(data.date).getTime() : Date.now() + 60000,
when: convertToTimestamp(data.date, data.time),
};
} else {
alarmInfo = {
Expand Down

0 comments on commit ede4efe

Please sign in to comment.