Skip to content

Commit

Permalink
add an "await review" script
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianHicks committed Sep 29, 2023
1 parent c118efd commit 4ad4b93
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 0 deletions.
30 changes: 30 additions & 0 deletions AwaitReview.omnifocusjs/Resources/awaitReview.js
@@ -0,0 +1,30 @@
"use strict";
(() => {
var action = new PlugIn.Action(async (selection) => {
try {
let originalTask = selection.tasks[0];
originalTask.flagged = false;
let followUp = new Task(`follow up for review on "${originalTask.name}"`, originalTask);
let when = new Date();
when.setDate(when.getDate() + 1);
// make sure we're not following up on a weekend
while (when.getDay() > 5) {
when.setDate(when.getDate() + 1);
}
// now that we've adjusted the date, set the correct time to defer
when.setHours(9);
when.setMinutes(0);
when.setSeconds(0);
when.setMilliseconds(0);
followUp.deferDate = when;
}
catch (err) {
console.error(err);
throw err;
}
});
action.validate = function (selection) {
return selection.tasks.length === 1;
};
return action;
})();
38 changes: 38 additions & 0 deletions AwaitReview.omnifocusjs/Resources/awaitReview.ts
@@ -0,0 +1,38 @@
(() => {
var action = new PlugIn.Action(async (selection: Selection) => {
try {
let originalTask: Task = selection.tasks[0];
originalTask.flagged = false;

let followUp = new Task(
`follow up for review on "${originalTask.name}"`,
originalTask
);

let when = new Date();
when.setDate(when.getDate() + 1);

// make sure we're not following up on a weekend
while (when.getDay() > 5) {
when.setDate(when.getDate() + 1);
}

// now that we've adjusted the date, set the correct time to defer
when.setHours(9);
when.setMinutes(0);
when.setSeconds(0);
when.setMilliseconds(0);

followUp.deferDate = when;
} catch (err) {
console.error(err);
throw err;
}
});

action.validate = function (selection: Selection) {
return selection.tasks.length === 1;
};

return action;
})();
@@ -0,0 +1,5 @@
"label" = "Await review";
"shortLabel" = "Await";
"mediumLabel" = "Await review";
"longLabel" = "Await review";
"paletteLabel" = "Await";
@@ -0,0 +1 @@
"zone.bytes.awaitReview" = "Await review";
13 changes: 13 additions & 0 deletions AwaitReview.omnifocusjs/manifest.json
@@ -0,0 +1,13 @@
{
"author": "Brian Hicks",
"identifier": "zone.bytes.awaitReview",
"defaultLocale": "en",
"version": "1.0",
"description": "Await Review",
"actions": [
{
"identifier": "awaitReview",
"image": "eyes"
}
]
}

0 comments on commit 4ad4b93

Please sign in to comment.