Skip to content

Commit

Permalink
Set the next review date of newly-created projects
Browse files Browse the repository at this point in the history
Set the next review date of a newly-created project to <review interval>
days/weeks/months/years after today.

If we don't do this, the newly-created project will inherit the review
date from the template, which is probably far in the past (i.e. whenever
the template was created), and the newly-created project will
immediately appear in the user's list of projects to review.  This is
probably not what the user wants, since they just created the project
and will presumably review it after creation.

Signed-off-by: Joshua Berry <des@condordes.net>
  • Loading branch information
josh-berry committed May 29, 2023
1 parent 3eb777f commit 34e7858
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion Templates.omnifocusjs/Resources/templateLibrary.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,32 @@
project = created.containingProject
}

if (created instanceof Project) created.status = Project.Status.Active // make status active if not already active
if (created instanceof Project) {
created.status = Project.Status.Active; // make status active if not already active

// Set the review date to today plus the review interval, on the
// assumption that the user is probably going to review the project as
// soon as it's created. If we don't do this, the review date of the
// original project will be used instead, which might be far in the past
// (e.g. when the template was first created).
const ri = created.reviewInterval;
const nextReviewDate = new Date();
switch (ri.unit) {
case 'days':
nextReviewDate.setDate(nextReviewDate.getDate() + ri.steps);
break;
case 'weeks':
nextReviewDate.setDate(nextReviewDate.getDate() + 7 * ri.steps);
break;
case 'months':
nextReviewDate.setMonth(nextReviewDate.getMonth() + ri.steps);
break;
case 'years':
nextReviewDate.setFullYear(nextReviewDate.getFullYear() + ri.steps);
break;
}
created.nextReviewDate = nextReviewDate;
}

// ASK ABOUT OPTIONAL TASKS
const optTasks = created.flattenedTasks.filter(task => task.note.includes('$OPTIONAL'))
Expand Down

0 comments on commit 34e7858

Please sign in to comment.