Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add_Note ID no longer works in Anki 2.1.29+ #138

Open
mnhende2 opened this issue Jul 30, 2020 · 4 comments
Open

Add_Note ID no longer works in Anki 2.1.29+ #138

mnhende2 opened this issue Jul 30, 2020 · 4 comments

Comments

@mnhende2
Copy link

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

@sarkologist
Copy link

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

@sarkologist
Copy link

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

@JackElsey
Copy link

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

@ambimorph
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants