From 5a90ac19f5a83431b30783c1350852425d1b7dec Mon Sep 17 00:00:00 2001 From: Brian Hicks Date: Thu, 15 Jun 2023 13:03:50 -0500 Subject: [PATCH] set task due dates from Linear --- Linear.omnifocusjs/Resources/pull.js | 7 ++++++- Linear.omnifocusjs/Resources/pull.ts | 14 +++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Linear.omnifocusjs/Resources/pull.js b/Linear.omnifocusjs/Resources/pull.js index ec73964..2bdf58c 100644 --- a/Linear.omnifocusjs/Resources/pull.js +++ b/Linear.omnifocusjs/Resources/pull.js @@ -27,7 +27,7 @@ /////////////////////////// req.method = "POST"; req.bodyString = - '{"query":"{ viewer { assignedIssues(filter: {state: {type: {nin: [\\"completed\\",\\"canceled\\"]}}}) { nodes { identifier title url team { name } project { name url } } } } }"}'; + '{"query":"{ viewer { assignedIssues(filter: {state: {type: {nin: [\\"completed\\",\\"canceled\\"]}}}) { nodes { identifier title url dueDate team { name } project { name url } } } } }"}'; req.headers = { "Content-Type": "application/json", Authorization: key, @@ -84,6 +84,11 @@ task.appendStringToNote(linearTask.url); } } + if (linearTask.dueDate) { + // set the date but strip off the time component + let date = new Date(linearTask.dueDate); + task.dueDate = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0); + } } if (app.platformName === "macOS") { document.windows[0].perspective = Perspective.BuiltIn.Projects; diff --git a/Linear.omnifocusjs/Resources/pull.ts b/Linear.omnifocusjs/Resources/pull.ts index b0185c5..bd49f1d 100644 --- a/Linear.omnifocusjs/Resources/pull.ts +++ b/Linear.omnifocusjs/Resources/pull.ts @@ -34,7 +34,7 @@ /////////////////////////// req.method = "POST"; req.bodyString = - '{"query":"{ viewer { assignedIssues(filter: {state: {type: {nin: [\\"completed\\",\\"canceled\\"]}}}) { nodes { identifier title url team { name } project { name url } } } } }"}'; + '{"query":"{ viewer { assignedIssues(filter: {state: {type: {nin: [\\"completed\\",\\"canceled\\"]}}}) { nodes { identifier title url dueDate team { name } project { name url } } } } }"}'; req.headers = { "Content-Type": "application/json", Authorization: key, @@ -104,6 +104,18 @@ task.appendStringToNote(linearTask.url); } } + if (linearTask.dueDate) { + // set the date but strip off the time component + let date = new Date(linearTask.dueDate); + task.dueDate = new Date( + date.getFullYear(), + date.getMonth(), + date.getDate(), + 0, + 0, + 0 + ); + } } if (app.platformName === "macOS") {