ospalh/anki-addons

Add_Note ID no longer works in Anki 2.1.29+

Opened this issue · 4 comments

I think the problem began a bit earlier that 2.1.29, but I was running a lower version for a few months.

I'm using anki 2.1.29. It always sets the note id to -1500000000000

i notice on master it is

def onLoadNote(self, *args, **kwargs):
for f in self.note.keys():
if f == config["NoteIdFieldName"] and not self.note[f]:
self.note[f] = str(uuid.uuid1())

but the code as downloaded from the anki addons page is

def onLoadNote(self, *args, **kwargs):
    for f in self.note.keys():
        if f == config["NoteIdFieldName"] and not self.note[f]:
            self.note[f] = str(self.note.id - int(15e11))

when i manually edit the extension locally to use uuid it works

Replacing the file __init__.py in the add-ons folder with the file from this repo fixed the problem for me.

i notice on master it is

def onLoadNote(self, *args, **kwargs):
for f in self.note.keys():
if f == config["NoteIdFieldName"] and not self.note[f]:
self.note[f] = str(uuid.uuid1())

but the code as downloaded from the anki addons page is

def onLoadNote(self, *args, **kwargs):
    for f in self.note.keys():
        if f == config["NoteIdFieldName"] and not self.note[f]:
            self.note[f] = str(self.note.id - int(15e11))

when i manually edit the extension locally to use uuid it works

If you want the old note id behaviour, instead of the uuid behaviour,
the fix for that is to check that the note id isn't - int(15e11) before adding anything.

I removed the subtraction, because for my purposes I need the note id to be the actual note id,
so in my case it was auto-filling with 0, because when you first open the add note form, there is no id yet.

I now have

if self.note.id != 0:
    self.note[f] = str(self.note.id)

in the onLoadNote section to avoid that, and the correct note id fills in next time it is opened.