kiwiz / gkeepapi

An unofficial client for the Google Keep API.
MIT License
1.53k stars 114 forks source link

Notes are created out of order #157

Closed yuvgin closed 9 months ago

yuvgin commented 9 months ago

I'm using gkeepapi to transfer notes into keep from another note app.

I have a dataframe of ~1000 notes that I iterate over. The dataframe is sorted by creation date (of the original notes) but when I sync they appear in keep in the wrong order (despite the fact that the node's timestamps are in the correct order). Any idea what's going on?

Running on Ubuntu with python 3.7

kiwiz commented 9 months ago

I believe there are two issues here:

For the behaviour you desire, you might have to call sync() after every new note.

yuvgin commented 9 months ago

Thanks for the quick reply. I tried syncing after every createNote, and also tried adding time.sleep after every sync. Didn't do the trick..

kiwiz commented 9 months ago

Oh, I understand now. The sorting of notes is defined via the sort attribute on notes, which is randomly generated. You can set it to a monotonically increasing/decreasing value:

for i, blah in enumerate(items):
    note = keep.createNote()
    note.sort = i
    ...
yuvgin commented 9 months ago

That works, thanks!! Perhaps add it to the docs, it seems important :)