christopherjwhite / org-toodledo

Emacs enhancement for syncing org-mode tasks with Toodledlo
83 stars 16 forks source link

Minimize calls to the server until syncing #25

Open christopherjwhite opened 10 years ago

christopherjwhite commented 10 years ago

Right now, any action that requires parsing the task requires name->id maps for folders, contexts, and goals, as well as whether this is a pro account. This is pulled from the server and cached in memory for the first such call. That means some actions, such as marking a task as deleted, require an internet connection if no sync has been completed yet.

Workaround - after opening the todo org-mode file, call org-sync while online, then don't close the emacs. This will cache the variables and should allow offline operations until org-toodledo-sync is called.

Refactor the code a bit to handle this. Two options in org-toodledo-parse-current-task:

  1. Don't convert names to ids here, just store the names and convert to ids at sync time. Need to also somehow delay actions based on pro-mode.
  2. Cache the name->id maps and pro-mode in properties in the file and refresh them on each org-sync.

Option 2 is probably the safer approach as far as coding goes, as it touches much less code.

lawlist commented 9 years ago

With respect to the function org-toodledo-mark-task-deleted, it does not appear essential to use org-toodledo-parse-current-task because only insertion of the ID into OrgToodledoPendingDeletes is needed. The ID can be obtained by using (org-entry-get (point) "ToodledoID"). Once that ID is inserted into OrgToodledoPendingDeletes, the task can be immediately archived in a separate file using org-archive-subtree or simply delete-region of same (depending on the value of org-toodledo-archive-deleted-tasks). As long as the master todo file is saved, synchronization can occur at a later time or a later date -- the server does not need to be contacted when simply deleting or archiving. Unless, I am missing something . . .?

The code refers in a few places to a property drawer with a name of "Deleted" and a potential value of 1; however, I could not find where (in the code) that property drawer is actually created. Has that been implemented yet?