I'm waiting to hear back from the reqwests author on the best way to
handle this. For now, this change just adds short timeouts
to the quick requests, and will wait for up to an hour when sending/
receiving files to allow for the slow connection+large file case.
The progress handling code needs a rethink, as we now have two separate
ways to flag that the media sync should abort. In the future, it may
make sense to switch to polling the backend for progress, instead of
passing a callback in.
- on collection load, the schema is upgraded to 12
- on collection close, the changes are reversed so older clients
can continue to open the collection
- in the future, we could potentially skip the reversal except
when exporting/doing a full sync
- the same approach should work for decks, note types and tags in the
future too
- the deck list code needs updating to cache the deck confs for the
life of the call
This reverts commit 2264fe3f66, reversing
changes made to 84b84ae31c.
Causes a traceback when opening the add screen, clicking on Type,
and choosing a note type.
File "/Users/dae/Work/code/dtop/qt/aqt/webview.py", line 31, in cmd
return json.dumps(self.onCmd(str))
File "/Users/dae/Work/code/dtop/qt/aqt/webview.py", line 97, in _onCmd
return self._onBridgeCmd(str)
File "/Users/dae/Work/code/dtop/qt/aqt/webview.py", line 500, in _onBridgeCmd
return self.onBridgeCmd(cmd)
File "/Users/dae/Work/code/dtop/qt/aqt/editor.py", line 374, in onBridgeCmd
self._links[cmd](self, *args) # type: ignore
File "/Users/dae/Work/code/dtop/qt/aqt/editor.py", line 404, in onBlur
if gui_hooks.editor_did_unfocus_field(False, self.note, int(ord)):
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
Initially, I wanted to solve the bug reported on
https://github.com/Arthur-Milchior/anki-html-src-in-field/issues/1
After some research, I finally discovered that the trouble was that,
when we change the note type in add card, the method
`aqt.editor.Editor.loadNote` is called twice. In itself, it would not
be a problem, but given the way callback works, its call back is
called twice on the last version of the webview. Which means that
`gui_hooks.editor_did_load_note` is called twice, which breaks this
add-on.
The reason why loadNote is called twice is because `setNote` is called
twice in `aqt.modelchooser.onModelChange`. The first time through
`gui_hooks.current_note_type_did_change` which calls
`addcards.AddCards.onModelChange` which calls `loadNote`, the second
time through `self.mw.reset()` which calls
`gui_hooks.state_did_reset()` which calls `addcards.AddCards.onReset`
which calls `setAndFocusNote` which calls `setNote`.
I should note furthermore that currently,
`gui_hooks.current_note_type_did_change` is called only when the model
chooser change a model. And `addCards.onModelChange` is never called,
only added to the hook `gui_hooks.current_note_type_did_change`. So
removing the line of code removed in this commit will have no side
effect in Anki itself. It will only affect the fact that this method
is called twice.
I do not know of any add-on calling `onModelChange` or
`gui_hooks.current_note_type_did_change`, but it means little, so of
course, it may always mean an add-on will break because of this
change. No way of being sure.
The reason to do that is that I can then call blur/key from other
method in add-on.
More precisely, I expect to create a method which captures the blur
command, ask anki to execute the standard version of the command, and
then execute more code once the note contains the new field value.
I should note that the code executed during blur/key/focus itself
didn't change. It's only it's location which changed.