HeroBlackInk / ultimate-todoist-sync-for-obsidian

GNU General Public License v3.0
145 stars 20 forks source link

Implement Sync Todoist -> Obsidian #67

Open Heiss opened 10 months ago

Heiss commented 10 months ago

This is the follow up PR for #66

Tasks:

Bugs:

Outside of this PR scope

Heiss commented 10 months ago

For documentation, i copied your comment from here:

Due to rate limits, each user is allowed to make a maximum of 45 full sync requests within a 15-minute period. It is recommended to utilize the REST API's 'Get active tasks' feature, which allows a maximum of 450 REST API requests per user within the same 15-minute timeframe.

import { TodoistApi } from "@doist/todoist-api-typescript"

const api = new TodoistApi("0123456789abcdef0123456789")

api.getTasks()
    .then((tasks) => console.log(tasks))
    .catch((error) => console.log(error))

Example response:

[ { creatorId: "2671355", createdAt: "2019-12-11T22:36:50.000000Z", assigneeId: "2671362", assignerId: "2671355", commentCount: 10, isCompleted: false, content: "Buy Milk", description: "", due: { date: "2016-09-01", isRecurring: false, datetime: "2016-09-01T09:00:00.000000Z", string: "tomorrow at 12", timezone: "Europe/Moscow" }, "duration": null, id: "2995104339", labels: ["Food", "Shopping"], order: 1, priority: 1, projectId: "2203306141", sectionId: "7025", parentId: "2995104589", url: "https://todoist.com/showTask?id=2995104339" } ]

Returns a JSON-encoded array containing all active tasks.

HeroBlackInk commented 10 months ago

I am a severe procrastinator, so I tend to be slower in everything I do. Please don't mind.

HeroBlackInk commented 10 months ago

Regarding bidirectional sync, I have used a lock mechanism where it checks if there is an ongoing sync task before each sync, and if there is, it prevents the current sync from executing. This method was also used for the reverse synchronization of content and dates, and so far, I haven't encountered any issues.

HeroBlackInk commented 10 months ago

I understand what you mean. Because there is no event notification for label updates, the only way to handle the issue of tag synchronization is to rely on the Incremental sync API. However, I haven't finished working on this module yet.

Heiss commented 10 months ago

Regarding bidirectional sync, I have used a lock mechanism where it checks if there is an ongoing sync task before each sync, and if there is, it prevents the current sync from executing. This method was also used for the reverse synchronization of content and dates, and so far, I haven't encountered any issues.

Okay, than i will look out for this to use it as well. Yesterday i had the issue, that a tag was added in todoist and another one was removed in obsidian. After this, it made some weird stuff. (But i think it only happens, because of my stuff. Nothing else)

I understand what you mean. Because there is no event notification for label updates, the only way to handle the issue of tag synchronization is to rely on the Incremental sync API. However, I haven't finished working on this module yet.

Give me a hint and i will see, what i can do.

I am a severe procrastinator, so I tend to be slower in everything I do. Please don't mind.

No problem. I had a free weekend with a lot of spare time. So it will take some time now, before i can make big steps again. But if you want to help me to find the correct documentation and lines of code to take a look at, i am very happy. :) So feel free to post links to any helpful page.

HeroBlackInk commented 10 months ago

Incremental sync

The Sync API allows clients to retrieve only updated resources, and this is done by using the sync_token in your Sync API request.

https://developer.todoist.com/sync/v8/#read-resources

Heiss commented 10 months ago

Incremental sync The Sync API allows clients to retrieve only updated resources, and this is done by using the sync_token in your Sync API request.

https://developer.todoist.com/sync/v8/#read-resources

Mh. Using the sync_token with sync seems to work great, but if you change the label / tag, it does not come up with the task again. Only description / content seems to trigger an "update" event, so you do not see it... AFAIK Only a full sync or a change in content / description / project / etc. would trigger a tag sync. :(

HeroBlackInk commented 10 months ago

Incremental sync The Sync API allows clients to retrieve only updated resources, and this is done by using the sync_token in your Sync API request.

https://developer.todoist.com/sync/v8/#read-resources

Mh. Using the sync_token with sync seems to work great, but if you change the label / tag, it does not come up with the task again. Only description / content seems to trigger an "update" event, so you do not see it... AFAIK Only a full sync or a change in content / description / project / etc. would trigger a tag sync. :(

I am sorry, I haven't tested this API before, it seems like my idea is wrong.

Heiss commented 9 months ago

So... After some weeks, i had time today to continue my journey with obsidian plugin :)

i think, my additions fixes #71 too.

Now, i need some time to do some cleanup and prettify the code. Currently, it is a mess in multiple places and is not KISS. But everything should be tested a lot! In my testing environemnt, it works great and as expected.

After the cleanup, i will install my changes in my production environment and test it a few days. But i do not know, when i have time to do this.

Because i have no other way to find out updates on todoist in some topics (e.g. for dueDate or labels), i assume that if there are changes on todoist side, these are the current ones. If someone changes on obsidian side, it will be checked by your existing code automatically and pushed to todoist ASAP. So there should be no need of strict update algorithm. But this breaks, if someone switches between todoist and obsidian between two synchronizations...

There are some things, i would like to add in another PR...

HeroBlackInk commented 9 months ago

I'm sorry, but I have been feeling quite terrible lately. I've been struggling to accomplish even simple tasks without someone to oversee me. If you know how to release a new version, you can simply merge it into the main branch and publish the updated version.

HeroBlackInk commented 9 months ago

How to Publish a New Release:

Step 1: Update version in 'manifest.json', and push it to the main branch.

git commit -am "new release"
git push origin main

step 2: release new version

git tag -a 1.0.44 -m "1.0.44"
git push origin 1.0.44
Heiss commented 9 months ago

I'm sorry, but I have been feeling quite terrible lately. I've been struggling to accomplish even simple tasks without someone to oversee me. If you know how to release a new version, you can simply merge it into the main branch and publish the updated version.

Ah, i am sorry to hear that. Hope, you get all help you need. Take your time. Thank you for assistance nevertheless. I take one step after another. ;)

Hope you get well soon.

Do not feel any pressure from my work on your plugin. I only do it in spare time and it is fun to work with. It is a hobby for me. So there is no pressure. ;)

HeroBlackInk commented 9 months ago

Thanks!

I am facing difficulties managing my time, and everything seems to be in a state of chaos.

Druzco commented 8 months ago

Looks really promising!

solace commented 8 months ago

Thank you both for your hard work with this and I hope you have some time to look after yourselves as well.

Suyashtnt commented 7 months ago

How stable is this to use? Also, hope stuff gets better for you @HeroBlackInk.