TaskDecay v1.0.0 MVP — smart task review & archive Chrome extension

This commit is contained in:
Bun Bun
2026-06-17 06:48:47 +00:00
commit cc9aee68ee
38 changed files with 4710 additions and 0 deletions
+60
View File
@@ -0,0 +1,60 @@
// TickTick API v2 — uses login token or OAuth access token
export async function fetchTickTickTasks(config) {
if (!config.token)
throw new Error('TickTick token not configured');
const headers = {
'Authorization': `Bearer ${config.token}`,
'Content-Type': 'application/json',
};
// Get all projects first
const projectsRes = await fetch('https://api.ticktick.com/open/v1/project', { headers });
const projects = projectsRes.ok ? await projectsRes.json() : [];
const projectList = Array.isArray(projects) ? projects : (projects || []);
const allTasks = [];
for (const proj of projectList) {
const pid = proj.id;
const tasksRes = await fetch(`https://api.ticktick.com/open/v1/project/${pid}/task`, { headers });
if (!tasksRes.ok)
continue;
const tasks = await tasksRes.json();
const taskList = Array.isArray(tasks) ? tasks : (tasks || []);
for (const t of taskList) {
if (t.status === 2)
continue; // completed
allTasks.push({
id: `ticktick-${t.id}`,
title: t.title,
priority: (t.priority || 0) + 1,
createdAt: new Date(t.createdTime || Date.now()),
updatedAt: new Date(t.modifiedTime || t.createdTime || Date.now()),
completedAt: null,
dueDate: t.dueDate ? new Date(t.dueDate) : null,
projectId: `ticktick-${pid}`,
projectName: proj.name || null,
labels: t.tags || [],
url: `https://ticktick.com/webapp/#p/${pid}/task/${t.id}`,
source: 'ticktick',
raw: t,
});
}
}
return allTasks;
}
export async function closeTickTickTask(taskId, token) {
const realId = taskId.replace('ticktick-', '');
const res = await fetch(`https://api.ticktick.com/open/v1/task/${realId}/complete`, {
method: 'POST',
headers: { 'Authorization': `Bearer ${token}` },
});
if (!res.ok)
throw new Error(`Failed to close TickTick task: ${res.status}`);
}
export async function deleteTickTickTask(taskId, token) {
const realId = taskId.replace('ticktick-', '');
const res = await fetch(`https://api.ticktick.com/open/v1/task/${realId}`, {
method: 'DELETE',
headers: { 'Authorization': `Bearer ${token}` },
});
if (!res.ok)
throw new Error(`Failed to delete TickTick task: ${res.status}`);
}