Commit Graph

3954 Commits

Author SHA1 Message Date
Damien Elmes
5b26b20697 explicitly save deck conf after mutating it 2020-03-30 12:27:52 +10:00
Damien Elmes
bf83715ee0 initial work on undo support 2020-03-29 17:52:16 +10:00
Damien Elmes
f90e5dbe2c remove usn cache
SqliteStorage no longer contains any mutable state
2020-03-29 12:50:38 +10:00
Damien Elmes
d1ecf33c72 cache timing_today in collection, update it when cutover reached 2020-03-29 12:26:24 +10:00
Damien Elmes
fdeca610b0 drop separate RequestContext/StorageContext 2020-03-29 12:12:35 +10:00
Damien Elmes
2810d3883b 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
1a1a00d50f Revert "add benchmark for vec cache"
This reverts commit 82ed288dc5.
2020-03-29 09:16:11 +10:00
Damien Elmes
ef79f7d676
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
47bd6264bd Revert "Merge pull request #527 from Arthur-Milchior/explode_on_bridge_cmd"
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'
2020-03-28 13:35:05 +10:00
Arthur Milchior
4bb49d404e hook browser_header_will_show_context_menu 2020-03-27 23:06:22 +01:00
Damien Elmes
158ce7bc01 add an extra second so slow CI server doesn't fail 2020-03-27 15:52:35 +10:00
Damien Elmes
d81c725b46
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
f6219b59ac
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
2264fe3f66
Merge pull request #527 from Arthur-Milchior/explode_on_bridge_cmd
Explode on bridge cmd
2020-03-27 15:22:14 +10:00
evandrocoan
3f8cc60abc 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
84b84ae31c use add_card() 2020-03-27 15:11:07 +10:00
Damien Elmes
6b9378fb41 add (unused) add_card, and move sql to separate files 2020-03-27 14:48:25 +10:00
evandrocoan
9bd28f151f Disabled the caches of cargo registry, index and python wheels 2020-03-27 00:21:09 -03:00
Damien Elmes
82ed288dc5 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
2f4e35d566 store cached statements in a vec instead of separate optionals 2020-03-27 09:51:19 +10:00
evandrocoan
76bf3f8a03 Created a fast build matrix for quickly running the Unit Tests 2020-03-26 19:43:16 -03:00
evandrocoan
b07454ca0c Merge remote-tracking branch 'danielelmes/master' into create_actions_for_windows_macos 2020-03-26 19:31:01 -03:00
Damien Elmes
369d2d89d9 update card in transaction 2020-03-27 07:58:25 +10:00
Arthur Milchior
0b633dbf40 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
c9496ef095 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
fe327e32ca 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
7f16f436c3 handle mtime/usn bump in backend, and tweak integer sizes 2020-03-26 20:55:04 +10:00
Damien Elmes
7a56d18539 report invalid type/queue 2020-03-26 19:32:35 +10:00
Damien Elmes
13c7c82ae3 fix two cases where a float was being written into due 2020-03-26 19:05:18 +10:00
Damien Elmes
47504245dc update_card() 2020-03-26 18:54:20 +10:00
Damien Elmes
1acfe7d3cc tweak code for mypy 2020-03-26 17:47:53 +10:00
Damien Elmes
7ddaf93f7a use backend to get card 2020-03-26 17:47:43 +10:00
evandrocoan
1e40103325 Moved RSPY_TARGET_DIR and CARGO_TARGET_DIR to the top 2020-03-26 03:04:47 -03:00
evandrocoan
8b8be3e3f3 Fixed misspelling Mac OS with a space on the build matrix 2020-03-26 02:46:18 -03:00
evandrocoan
96d572c3cc Merged all workflows together using build matrixes 2020-03-26 02:11:34 -03:00
Damien Elmes
8abba00496 DeckID, CardID 2020-03-26 15:10:40 +10:00
Damien Elmes
f52e775354 NoteTypeID 2020-03-26 15:00:24 +10:00
Damien Elmes
4ec30e412a newtype NoteID 2020-03-26 14:42:43 +10:00
evandrocoan
e1252b785d Fixed checks.yml Mac OS gmake PATH being set on Ubuntu 2020-03-26 01:20:00 -03:00
Damien Elmes
5eed3d7f71 use a macro for newtype defs 2020-03-26 13:50:20 +10:00
Damien Elmes
39f916a23e usn newtype 2020-03-26 13:06:02 +10:00
Damien Elmes
eb89a2db3f use newtypes for distinguishing between second and millisecond stamps 2020-03-26 12:59:51 +10:00
evandrocoan
c8e2c25e83 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
65b8988817 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
Damien Elmes
8c80f96314 high due numbers shouldn't force a full sync 2020-03-26 09:09:11 +10:00
evandrocoan
b94936a98d Update make to use the new .SHELLFLAGS feature
https://github.com/ankitects/anki/pull 528
2020-03-25 19:05:31 -03:00
evandrocoan
1965cdb2b8 Set to use ankitects/setup-protoc@master instead of the original
repository with a `repo-token` until know whether it is safe to
pass the GitHub token around:
https://github.com/actions/virtual-environments/issues 602
2020-03-25 19:05:31 -03:00
evandrocoan
b77462eb8a Fixed lower case of runs-on: macos-latest
Accordingly to the documentation the name is lower case:
https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners
2020-03-25 19:05:31 -03:00
evandrocoan
53b89adeeb Fix for indentation not using tabs on the make file 2020-03-25 19:05:31 -03:00
evandrocoan
eab11622fd Re-enabled the Makefile set -eo commands because by default
Mac OS uses an old version of make which does not support
the .SHELLFLAGS feature.
2020-03-25 19:05:31 -03:00