HeroBlackInk / ultimate-todoist-sync-for-obsidian

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

Implement Sync Todoist -> Obsidian #66

Closed Heiss closed 10 months ago

Heiss commented 10 months ago

Hi,

because i need this functionality for my own workflow, i implement it myself, today. This is my first contribution to obsidian, so feel free to give some hints. Also there were some mistakes by myself with my IDE, because it tries to force me to use the code linter. But i do not found any information about the settings, the author used.

After this PR you can now:

This should implement the most of wanted features for #53

Missing things:

So hopefully, we can get a step closer to the ultimate sync plugin.

One thing, i would like to add: Maybe we should start to translate everything to english, so more people can help. Also we should introduce a common linter config. I have no hard feelings here, so feel free to decide. :)

I am looking forward to hear from you. Have a great day.

HeroBlackInk commented 10 months ago

This messy code, written a few months ago, is difficult for me to read, and there are also numerous Chinese comments interspersed throughout... However, you managed to implement a new feature in just two days. I am truly amazed... Thumbs up!

HeroBlackInk commented 10 months ago

Thank you very much for your contribution. I need some time to review the pull request, please be patient.

Heiss commented 10 months ago

You are welcome. 👍 Thank you for your great plugin, too. I was able to use a lot of already prepared function, which made it easier.

Heiss commented 10 months ago

I added the labels / tags to new tasks coming from todoist. In the same situation, i try to implement a sync, but I don't find a way to implement with the REST api... because todoist do not show an event for this kind of change.

Also i add a new setting to strip only the # from tags, because i need this for my use case. I use tags in flow with my text and the todoist tasks are awkward to read, if they are missing. So i added this shorthand. But the default setting is to strip the whole thing from the text as before, so nobody will be effected by this change.

HeroBlackInk commented 10 months ago

I added the labels / tags to new tasks coming from todoist. In the same situation, i try to implement a sync, but I don't find a way to implement with the REST api... because todoist do not show an event for this kind of change.

Yes, the information provided by the sync API is more comprehensive, but I haven't finished this part yet.

Heiss commented 10 months ago

The labels will now be synced with the help of full sync function. Currently, it checks if there are labels in tasks (or are missing) and places the tags at the end of line or remove them.

This assumes, that the user does not change anything in the vault by hand (e.g. with obsidian) because they are not send to todoist. If there are changes in todoist, too, we get a race condition, which is undefinied behaviour. So i add a check in settings to disable this feature per default.

Maybe you know a better workflow. But i cannot say, which change comes earlier in time, so we have here a first come first serve situation. :(

HeroBlackInk commented 10 months ago

I would like to invite you to become a collaborator and have also created a dev branch where you can submit your contributions without requiring approval. This will allow me to test and modify the code more conveniently.

HeroBlackInk commented 10 months ago

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

Thank you very much for your contribution.Please withdraw this merge request and merge it into the dev branch for testing convenience.

Heiss commented 10 months ago

Done. Changes are now pushed in dev branch. PR #67