Skip to content

Commit

Permalink
1.0.26 (#119)
Browse files Browse the repository at this point in the history
* Fix: full vault sync fix, mark completion fix
#104
#90

* Fix: TickTick has once again changed checkpoint processing.
closes #113
#111

... and get rid of extraneous logging.

* Fix: More Checkpoint foo. Issue with #ticktick regex.
#116

* Fix: versions
  • Loading branch information
thesamim committed Apr 12, 2024
1 parent ff304da commit d9b8c61
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 17 deletions.
2 changes: 1 addition & 1 deletion 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",
Expand Down
6 changes: 3 additions & 3 deletions main.ts
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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}`);
}


Expand Down
2 changes: 1 addition & 1 deletion 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",
Expand Down
2 changes: 1 addition & 1 deletion 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": {
Expand Down
10 changes: 8 additions & 2 deletions src/api/index.ts
Expand Up @@ -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) {
Expand All @@ -68,7 +73,7 @@ export class Tick {
this.loginUrl = `${protocol}${ticktickServer}${apiVersion}`;
this.originUrl = `${protocol}${ticktickServer}`;
}
this.checkpoint = 0;
this.checkpoint = -1;
}


Expand Down Expand Up @@ -128,7 +133,7 @@ export class Tick {

async getInboxProperties(): Promise<boolean> {
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)
Expand Down Expand Up @@ -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
}
Expand Down
4 changes: 0 additions & 4 deletions src/api/utils/get-api-endpoints.ts
Expand Up @@ -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',
Expand Down
20 changes: 17 additions & 3 deletions src/syncModule.ts
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand All @@ -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))
Expand Down Expand Up @@ -1070,15 +1073,15 @@ 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
const tasksUpdatedInObsidian = tasksInCache.filter(task => {
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 => {
Expand Down Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion src/taskParser.ts
Expand Up @@ -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(.*?)%/,
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion versions.json
Expand Up @@ -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"
}

0 comments on commit d9b8c61

Please sign in to comment.