Commit graph

3810 commits

Author SHA1 Message Date
Damien Elmes
284ee0860b allow aborting a media sync while http req in flight
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.
2020-04-01 09:49:25 +10:00
Damien Elmes
6a352e32ff Merge pull request #533 from zjosua/taglimit-quotes
Use double quotes in taglimit queries
2020-03-30 21:44:33 +10:00
Damien Elmes
6482af7361 add a temporary cache to bring deck list performance back 2020-03-30 20:27:53 +10:00
Damien Elmes
cffe146397 split deck config into separate SQL table
- 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
2020-03-30 20:01:16 +10:00
zjosua
487d02fff2 Use double quotes in taglimit queries 2020-03-30 10:12:47 +02:00
Damien Elmes
089a68eb43 move deck conf handling to backend 2020-03-30 14:39:46 +10:00
Damien Elmes
918ec2a5a0 explicitly save deck conf after mutating it 2020-03-30 12:27:52 +10:00
Damien Elmes
d41124343d initial work on undo support 2020-03-29 17:52:16 +10:00
Damien Elmes
3924dedbb7 remove usn cache
SqliteStorage no longer contains any mutable state
2020-03-29 12:50:38 +10:00
Damien Elmes
cbbbced59e cache timing_today in collection, update it when cutover reached 2020-03-29 12:26:24 +10:00
Damien Elmes
0451a4d4e0 drop separate RequestContext/StorageContext 2020-03-29 12:12:35 +10:00
Damien Elmes
c4a78ffd82 roll back the vec cache changes
prepare_cached() is sufficiently fast, and allowing the vec cache
to persist across calls is complicated due to lifetime restrictions
2020-03-29 09:26:09 +10:00
Damien Elmes
cb03c87f8b Revert "add benchmark for vec cache"
This reverts commit 0247d65ccd.
2020-03-29 09:16:11 +10:00
Damien Elmes
2fdca03043 Merge pull request #531 from Arthur-Milchior/browser_will_show_context_menu
hook browser_header_will_show_context_menu
2020-03-28 14:50:02 +10:00
Damien Elmes
76dec75947 Revert "Merge pull request #527 from Arthur-Milchior/explode_on_bridge_cmd"
This reverts commit 9e6a2ba1e6, reversing
changes made to fc846ac4e4.

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'
2020-03-28 13:35:05 +10:00
Arthur Milchior
015d07ec56 hook browser_header_will_show_context_menu 2020-03-27 23:06:22 +01:00
Damien Elmes
db3538aae3 add an extra second so slow CI server doesn't fail 2020-03-27 15:52:35 +10:00
Damien Elmes
ccee3af22c Merge pull request #529 from Arthur-Milchior/load_note_once_on_note_type_change
Ensuring "setNote" is called only once during changing of note type
2020-03-27 15:28:49 +10:00
Damien Elmes
36314f3b6f Merge pull request #528 from evandroforks/create_actions_for_windows_macos
Create actions for Windows and Mac OS
2020-03-27 15:26:22 +10:00
Damien Elmes
9e6a2ba1e6 Merge pull request #527 from Arthur-Milchior/explode_on_bridge_cmd
Explode on bridge cmd
2020-03-27 15:22:14 +10:00
evandrocoan
9224290336 Re-enabled the rust cargo index and registry caches because
cargo was downloading them just for nothing.
https://github.com/ankitects/anki/pull 528
2020-03-27 02:21:48 -03:00
Damien Elmes
fc846ac4e4 use add_card() 2020-03-27 15:11:07 +10:00
Damien Elmes
1112fc8e8b add (unused) add_card, and move sql to separate files 2020-03-27 14:48:25 +10:00
evandrocoan
399eb536a1 Disabled the caches of cargo registry, index and python wheels 2020-03-27 00:21:09 -03:00
Damien Elmes
0247d65ccd add benchmark for vec cache
test storage::sqlite::bench::bench_hash_cache ... bench:         399 ns/iter (+/- 27)
test storage::sqlite::bench::bench_no_cache   ... bench:       4,854 ns/iter (+/- 499)
test storage::sqlite::bench::bench_vec_cache  ... bench:           0 ns/iter (+/- 0)
2020-03-27 09:59:48 +10:00
Damien Elmes
d1c44ec06d store cached statements in a vec instead of separate optionals 2020-03-27 09:51:19 +10:00
evandrocoan
b9c89fbdff Created a fast build matrix for quickly running the Unit Tests 2020-03-26 19:43:16 -03:00
evandrocoan
f1fe0209f6 Merge remote-tracking branch 'danielelmes/master' into create_actions_for_windows_macos 2020-03-26 19:31:01 -03:00
Damien Elmes
62be1b2688 update card in transaction 2020-03-27 07:58:25 +10:00
Arthur Milchior
77e6e2eb69 Ensuring "setNote" is called only once during changing of note type
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.
2020-03-26 21:26:13 +01:00
Arthur Milchior
504b89f7af Ensure that focus, key and blur are treated as other commands
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.
2020-03-26 15:42:27 +01:00
Damien Elmes
0f0b90d427 fix progress dialog preventing schema mod
https://anki.tenderapp.com/discussions/beta-testing/1868-anki-2124-beta#comment_48183062

This is an ugly hack - in the future the calling code should be updated
to perform the check prior to starting the operation instead.
2020-03-26 21:07:53 +10:00
Damien Elmes
e28fdde984 handle mtime/usn bump in backend, and tweak integer sizes 2020-03-26 20:55:04 +10:00
Damien Elmes
aa33bf85ef report invalid type/queue 2020-03-26 19:32:35 +10:00
Damien Elmes
369457a1c7 fix two cases where a float was being written into due 2020-03-26 19:05:18 +10:00
Damien Elmes
0510ab7c9c update_card() 2020-03-26 18:54:20 +10:00
Damien Elmes
245a31a432 tweak code for mypy 2020-03-26 17:47:53 +10:00
Damien Elmes
b2fba4e1ff use backend to get card 2020-03-26 17:47:43 +10:00
evandrocoan
e97801498f Moved RSPY_TARGET_DIR and CARGO_TARGET_DIR to the top 2020-03-26 03:04:47 -03:00
evandrocoan
52f45a52f6 Fixed misspelling Mac OS with a space on the build matrix 2020-03-26 02:46:18 -03:00
evandrocoan
b6af705817 Merged all workflows together using build matrixes 2020-03-26 02:11:34 -03:00
Damien Elmes
1af3de6f70 DeckID, CardID 2020-03-26 15:10:40 +10:00
Damien Elmes
4150480709 NoteTypeID 2020-03-26 15:00:24 +10:00
Damien Elmes
3395a565a6 newtype NoteID 2020-03-26 14:42:43 +10:00
evandrocoan
6f8797fd69 Fixed checks.yml Mac OS gmake PATH being set on Ubuntu 2020-03-26 01:20:00 -03:00
Damien Elmes
bb0b817d9c use a macro for newtype defs 2020-03-26 13:50:20 +10:00
Damien Elmes
d95cb93d7a usn newtype 2020-03-26 13:06:02 +10:00
Damien Elmes
bfc0287e51 use newtypes for distinguishing between second and millisecond stamps 2020-03-26 12:59:51 +10:00
evandrocoan
49a8743527 Fix Mac OS checks.yml caches being rebuilt by stop using
the CARGO_TARGET_DIR and CARGO_INDEX_DIR variables:
https://github.com/ankitects/anki/pull 528
2020-03-25 22:42:37 -03:00
Damien Elmes
3ca9f61733 reduce the chances of add-ons preventing collections from loading
https://anki.tenderapp.com/discussions/ankidesktop/39953-sync-fail-with-images#comment_48182205
2020-03-26 09:53:15 +10:00