TUI for Todoist written with React+Ink.
0

Configure Feed

Select the types of activity you want to include in your feed.

cache projects for five minutes

Aly Raffauf (Feb 14, 2026, 10:41 PM EST) aa9c2949 d7b5c14f

+17 -5
+17 -5
source/app.tsx
··· 21 21 22 22 const api = new TodoistApi(apiToken); 23 23 24 + const PROJECT_CACHE_TTL = 5 * 60 * 1000; 25 + let cachedProjects: Map<string, string> | null = null; 26 + let cachedProjectsAt = 0; 27 + 24 28 function CommandHints({input}: {input: string}) { 25 29 if (input === '?') { 26 30 return commands.map(c => ( ··· 97 101 98 102 setLoading(true); 99 103 104 + const projectsStale = 105 + !cachedProjects || Date.now() - cachedProjectsAt > PROJECT_CACHE_TTL; 106 + 100 107 const [taskResponse, projectResponse] = await Promise.all([ 101 108 api.getTasksByFilter({query: view.query}), 102 - api.getProjects(), 109 + projectsStale ? api.getProjects() : null, 103 110 ]); 104 111 105 - const projectMap = new Map<string, string>(); 106 - for (const project of projectResponse.results) { 107 - projectMap.set(project.id, project.name); 112 + if (projectResponse) { 113 + const projectMap = new Map<string, string>(); 114 + for (const project of projectResponse.results) { 115 + projectMap.set(project.id, project.name); 116 + } 117 + 118 + cachedProjects = projectMap; 119 + cachedProjectsAt = Date.now(); 108 120 } 109 121 110 - setProjects(projectMap); 122 + setProjects(cachedProjects!); 111 123 setTasks(taskResponse.results); 112 124 setLoading(false); 113 125 }, [view]);