From d9b8c618010bbeb088a22a7f05d16e82c38d383c Mon Sep 17 00:00:00 2001 From: thesamim Date: Fri, 12 Apr 2024 11:27:45 -0500 Subject: [PATCH] 1.0.26 (#119) * Fix: full vault sync fix, mark completion fix https://github.com/thesamim/TickTickSync/issues/104 https://github.com/thesamim/TickTickSync/issues/90 * Fix: TickTick has once again changed checkpoint processing. closes https://github.com/thesamim/TickTickSync/issues/113 https://github.com/thesamim/TickTickSync/issues/111 ... and get rid of extraneous logging. * Fix: More Checkpoint foo. Issue with #ticktick regex. https://github.com/thesamim/TickTickSync/issues/116 * Fix: versions --- dist/manifest.json | 2 +- main.ts | 6 +++--- manifest.json | 2 +- package.json | 2 +- src/api/index.ts | 10 ++++++++-- src/api/utils/get-api-endpoints.ts | 4 ---- src/syncModule.ts | 20 +++++++++++++++++--- src/taskParser.ts | 8 +++++++- versions.json | 3 ++- 9 files changed, 40 insertions(+), 17 deletions(-) diff --git a/dist/manifest.json b/dist/manifest.json index de83853..eacb36f 100644 --- a/dist/manifest.json +++ b/dist/manifest.json @@ -1,7 +1,7 @@ { "id": "tickticksync", "name": "TickTickSync", - "version": "1.0.26", + "version": "1.0.27", "minAppVersion": "1.0.0", "description": "Sync TickTick tasks to Obsidian, and Obsidian tasks to TickTick", "author": "thesamim", diff --git a/main.ts b/main.ts index ca6eb07..227d916 100644 --- a/main.ts +++ b/main.ts @@ -119,12 +119,12 @@ export default class TickTickSync extends Plugin { if ((!markDownView) || !(editor) || (editor) && !(editor.hasFocus())) { - // (console.log(`editor is not focused`)) + (console.log(`editor is not focused`)) return; } if (evt.key === 'ArrowUp' || evt.key === 'ArrowDown' || evt.key === 'ArrowLeft' || evt.key === 'ArrowRight' || evt.key === 'PageUp' || evt.key === 'PageDown') { - //console.log(`${evt.key} arrow key is released`); + // console.log(`${evt.key} arrow key is released`); if (!(this.checkModuleClass())) { return; } @@ -521,7 +521,7 @@ export default class TickTickSync extends Plugin { if (this.lastLines.has(fileName as string) && line !== this.lastLines.get(fileName as string)) { const lastLine = this.lastLines.get(fileName as string); if (this.settings.debugMode) { - // console.log('Line changed!', `current line is ${line}`, `last line is ${lastLine}`); + console.log('Line changed!', `current line is ${line}`, `last line is ${lastLine}`); } diff --git a/manifest.json b/manifest.json index de83853..eacb36f 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "tickticksync", "name": "TickTickSync", - "version": "1.0.26", + "version": "1.0.27", "minAppVersion": "1.0.0", "description": "Sync TickTick tasks to Obsidian, and Obsidian tasks to TickTick", "author": "thesamim", diff --git a/package.json b/package.json index 8634b85..366e88a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tickticksync", - "version": "1.0.26", + "version": "1.0.27", "description": "Sync TickTick tasks to Obsidian, and Obsidian tasks to TickTick", "main": "main.js", "scripts": { diff --git a/src/api/index.ts b/src/api/index.ts index 962cecc..4cc3ea9 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -50,6 +50,11 @@ export class Tick { apiUrl: string; loginUrl: string; private originUrl: string; + +//Dear Future me: the check is a checkpoint based thing. As in: give me everything after a certain checkpoint +// 0 behavior has become non-deterministic. It appears that checkpoint is a epoch number. +// I **think** it indicates the time of last fetch. This could be useful. +//TODO: in the fullness of time, figure out checkpoint processing to reduce traffic. private checkpoint: number; constructor({ username, password, baseUrl, token }: IoptionsProps) { @@ -68,7 +73,7 @@ export class Tick { this.loginUrl = `${protocol}${ticktickServer}${apiVersion}`; this.originUrl = `${protocol}${ticktickServer}`; } - this.checkpoint = 0; + this.checkpoint = -1; } @@ -128,7 +133,7 @@ export class Tick { async getInboxProperties(): Promise { try { - let checkPoint = 0; + let checkPoint = this.checkpoint; for (let i = 0; i < 10; i++) { const url = `${this.apiUrl}/${allTasksEndPoint}` + checkPoint; // console.log("url ", url) @@ -627,6 +632,7 @@ private createLoginRequestOptions(url: string, body: JSON) { } } private getNextCheckPoint() { + console.warn("Check point has been changed.", this.checkpoint); this.checkpoint += 1; return this.checkpoint } diff --git a/src/api/utils/get-api-endpoints.ts b/src/api/utils/get-api-endpoints.ts index fb97e20..0eea9a6 100644 --- a/src/api/utils/get-api-endpoints.ts +++ b/src/api/utils/get-api-endpoints.ts @@ -7,10 +7,6 @@ const API_ENDPOINTS = { apiVersion: '/api/v2', signInEndPoint: 'user/signon?wc=true&remember=true', userPreferencesEndPoint: 'user/preferences/settings', -//Dear Future me: the check is a checkpoint based thing. As in: give me everything after a certain checkpoing -// 0 behavior has become non-deterministic -//TODO: in the fullness of time, figure out checkpoint processing to reduce traffic. - // generalDetailsEndPoint: 'batch/check/0', allProjectsEndPoint: 'projects', allHabitsEndPoint: 'habits', allTagsEndPoint: 'tags', diff --git a/src/syncModule.ts b/src/syncModule.ts index 7e1eb3b..7737419 100644 --- a/src/syncModule.ts +++ b/src/syncModule.ts @@ -957,6 +957,7 @@ export class SyncMan { } let bModifiedFileSystem = false; let allTaskDetails = await this.plugin.tickTickRestAPI?.getAllTasks(); + console.log("All task details have been saved.", allTaskDetails); let tasksFromTickTic = allTaskDetails.update; let deletedTasks = allTaskDetails.delete; @@ -987,6 +988,7 @@ export class SyncMan { return; } } + // this.dumpArray('== remote:', tasksFromTickTic); let tasksInCache = await this.plugin.cacheOperation?.loadTasksFromCache() if (this.plugin.settings.debugMode) { console.log("We have: ", tasksFromTickTic.length, " tasks on " + this.plugin.tickTickRestAPI?.api?.apiUrl) @@ -997,6 +999,7 @@ export class SyncMan { tasksFromTickTic = tasksFromTickTic.sort((a, b) => (a.id > b.id) ? 1 : ((b.id > a.id) ? -1 : 0)) // console.log("num remote tasks: ", tasksFromTickTic.length) + // this.dumpArray('== local:', tasksInCache); if (tasksInCache) { tasksInCache = tasksInCache.sort((a, b) => (a.id > b.id) ? 1 : ((b.id > a.id) ? -1 : 0)) @@ -1070,7 +1073,7 @@ export class SyncMan { const modifiedTask = tasksInCache.find(t => t.id === task.id); return modifiedTask && (new Date(modifiedTask.modifiedTime) < new Date(task.modifiedTime)); }); - //this.dumpArray('Tasks Updated in TickTick:', tasksUpdatedInTickTick); + // this.dumpArray('Tasks Updated in TickTick:', tasksUpdatedInTickTick); // Check for updated tasks in Obsidian @@ -1078,7 +1081,7 @@ export class SyncMan { const modifiedTask = tasksFromTickTic.find(t => t.id === task.id); return modifiedTask && (new Date(modifiedTask.modifiedTime) > new Date(task.modifiedTime)); }); - //this.dumpArray('Tasks updated in Obsidian:', tasksUpdatedInObsidian); + // this.dumpArray('Tasks updated in Obsidian:', tasksUpdatedInObsidian); // // Check for updated tasks in Obsidian // const updatedObsidianTasks = tasksInCache.filter(task => { @@ -1141,7 +1144,18 @@ export class SyncMan { dumpArray(which: string, arrayIn: ITask[]) { console.log(which) - arrayIn.forEach(item => console.log(" ", item.id, "--", item.title, item.parentId, item.childIds, "modification time: ", item.modifiedTime)) + arrayIn.forEach(item => { + if (item.id == '661933d3a8876ef48c564ba4') { + console.log(' ', + item.id, '--', + // item.title, + // item.parentId, + // item.childIds, + 'modification time: ', item.modifiedTime); + } + } + ) + } ///End of Test diff --git a/src/taskParser.ts b/src/taskParser.ts index 909b824..afefcc6 100644 --- a/src/taskParser.ts +++ b/src/taskParser.ts @@ -86,7 +86,9 @@ const status_regex = "^\\s*(-|\\*)\\s+\\[(x| )\\]\\s" const REGEX = { //hopefully tighter find. - TickTick_TAG: new RegExp(`(?<=[ ;])${keywords.TickTick_TAG}+`, 'i'), + //TickTick_TAG: new RegExp(`(?<=[ ;])\\s${keywords.TickTick_TAG}+`, 'i'), + TickTick_TAG: new RegExp(`^[\\s]*[-] \\[[x ]\\] [\\s\\S]*${keywords.TickTick_TAG}[\\s\\S]*$`, "i"), + TickTick_ID: /\[ticktick_id::\s*[\d\S]+\]/, TickTick_ID_NUM: /\[ticktick_id::\s*(.*?)\]/, TickTick_ID_DV_NUM: /ticktick_id(.*?)%/, @@ -358,7 +360,11 @@ export class TaskParser { } hasTickTickTag(text: string) { + if (this.isMarkdownTask(text)) { + // console.log("hasTickTickTag", `${text} + // ${REGEX.TickTick_TAG} + // ${REGEX.TickTick_TAG.test(text)}`); return REGEX.TickTick_TAG.test(text); } else { return false; diff --git a/versions.json b/versions.json index d3c75fe..b654135 100644 --- a/versions.json +++ b/versions.json @@ -21,5 +21,6 @@ "1.0.23": "1.0.0", "1.0.24": "1.0.0", "1.0.25": "1.0.0", - "1.0.26": "1.0.0" + "1.0.26": "1.0.0", + "1.0.27": "1.0.0" } \ No newline at end of file