Skip to content
This repository has been archived by the owner on Mar 13, 2023. It is now read-only.

Commit

Permalink
fix(todoist): task cache not being refreshed
Browse files Browse the repository at this point in the history
  • Loading branch information
moranje committed Feb 25, 2020
1 parent 23f57a1 commit 179c0bc
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 128 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ module.exports = {
allow: [
'project_id',
'label_ids',
'label_id',
'section_id',
'due_string',
'due_date',
Expand Down
53 changes: 0 additions & 53 deletions assets/info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,6 @@
<false/>
</dict>
</array>
<key>425292E2-8641-4346-A537-F128D473408C</key>
<array>
<dict>
<key>destinationuid</key>
<string>853C0BDB-9C62-4715-86A4-E71735849C80</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
</array>
<key>853C0BDB-9C62-4715-86A4-E71735849C80</key>
<array>
<dict>
Expand Down Expand Up @@ -173,39 +160,6 @@ node $node_flags alfred-workflow-todoist.js "{query}"</string>
<key>version</key>
<integer>2</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>action</key>
<integer>0</integer>
<key>argument</key>
<integer>3</integer>
<key>argumenttext</key>
<string>Get milk #Projecten&lt;2222894826&gt; @10min&lt;537752121&gt; @opleiding&lt;2150940159&gt; !!1 ::Doing&lt;1786288&gt;, morgen 10 uur</string>
<key>focusedappvariable</key>
<false/>
<key>focusedappvariablename</key>
<string></string>
<key>hotkey</key>
<integer>17</integer>
<key>hotmod</key>
<integer>1048576</integer>
<key>hotstring</key>
<string>T</string>
<key>leftcursor</key>
<false/>
<key>modsmode</key>
<integer>0</integer>
<key>relatedAppsMode</key>
<integer>0</integer>
</dict>
<key>type</key>
<string>alfred.workflow.trigger.hotkey</string>
<key>uid</key>
<string>425292E2-8641-4346-A537-F128D473408C</string>
<key>version</key>
<integer>2</integer>
</dict>
<dict>
<key>config</key>
<dict>
Expand Down Expand Up @@ -364,13 +318,6 @@ node $node_flags alfred-workflow-todoist.js "{\"name\": \"readSettings\", \"args
<key>ypos</key>
<integer>220</integer>
</dict>
<key>425292E2-8641-4346-A537-F128D473408C</key>
<dict>
<key>xpos</key>
<integer>80</integer>
<key>ypos</key>
<integer>220</integer>
</dict>
<key>853C0BDB-9C62-4715-86A4-E71735849C80</key>
<dict>
<key>colorindex</key>
Expand Down
101 changes: 31 additions & 70 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"nearley": "2.19.1",
"new-github-issue-url": "^0.2.1",
"open": "^7.0.2",
"todoist-rest-api": "1.3.2",
"todoist-rest-api": "1.3.3",
"write-json-file": "4.3.0"
},
"devDependencies": {
Expand Down Expand Up @@ -107,8 +107,8 @@
"@types/node": "13.7.4",
"@types/shelljs": "0.8.6",
"@types/write-json-file": "3.2.1",
"@typescript-eslint/eslint-plugin": "2.20.0",
"@typescript-eslint/parser": "2.20.0",
"@typescript-eslint/eslint-plugin": "2.21.0",
"@typescript-eslint/parser": "2.21.0",
"@wessberg/cjs-to-esm-transformer": "0.0.18",
"@wessberg/rollup-plugin-ts": "^1.2.17",
"babel-jest": "^25.1.0",
Expand Down
2 changes: 2 additions & 0 deletions src/lib/todoist/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ export function requestError(error: Error): AlfredError {
return new AlfredError(Errors.TodoistAPIError, error.message, {
error,
title: 'The request to the API failed',
// @ts-ignore
url: error.url,
isSafe: true,
});
}
12 changes: 10 additions & 2 deletions src/lib/todoist/local-rest-adapter/local-task-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,19 @@ export default class LocalTaskAdapter<
}): Promise<GetResourceByName<Name>[]> {
const cache = this.peekAll() as GetResourceByName<Name>[];

if (cache.length > 0 && !options?.skipCache && !options?.filter) {
if (cache.length > 0 && options?.skipCache !== true && !options?.filter) {
return cache;
}

const remote = await this.taskAdapter.findAll(options);
// Shouldn't be passed along to the API request
const parameters = {
project_id: options?.project_id,
label_id: options?.label_id,
filter: options?.filter,
lang: options?.lang,
};

const remote = await this.taskAdapter.findAll(parameters);
if (!equal(remote, this.store.get(this.type))) {
const typeSafeRemote = remote as Store[Name];
this.store.set(this.type, typeSafeRemote);
Expand Down

0 comments on commit 179c0bc

Please sign in to comment.