Commit Graph

3816 Commits

Author SHA1 Message Date
Damien Elmes
28380d4183
Merge pull request #534 from Arthur-Milchior/tags_hook
hook tag_editor_received_a_key
2020-04-01 17:10:31 +10:00
Damien Elmes
d396460332 ignore .DS_Store in trash
https://anki.tenderapp.com/discussions/ankidesktop/40035-anki-2123-on-macos-ds_store-files-in-new-anki-trash
2020-04-01 13:37:57 +10:00
Damien Elmes
5fe747f14a left-align tags
https://anki.tenderapp.com/discussions/ankidesktop/40068-tags-column-in-browser-is-centered
2020-04-01 13:29:42 +10:00
Damien Elmes
c050833aba always position selection in center after search
https://anki.tenderapp.com/discussions/beta-testing/1888-retaining-position-when-searching
2020-04-01 11:01:20 +10:00
Damien Elmes
6495240914 add some timeouts
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.
2020-04-01 10:03:54 +10:00
Damien Elmes
c9da4bc1a6 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
Arthur Milchior
4b34e71030 hook tag_editor_received_a_key
I expect it to be useful for add-ons such as
https://github.com/fonol/anki-search-inside-add-card which interact
with the tag line
2020-03-31 15:05:41 +02:00
Damien Elmes
cb5b122c7c
Merge pull request #533 from zjosua/taglimit-quotes
Use double quotes in taglimit queries
2020-03-30 21:44:33 +10:00
Damien Elmes
fa2965d39a add a temporary cache to bring deck list performance back 2020-03-30 20:27:53 +10:00
Damien Elmes
35c03af520 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
bfdb5d01b5 Use double quotes in taglimit queries 2020-03-30 10:12:47 +02:00
Damien Elmes
004cc2b5f8 move deck conf handling to backend 2020-03-30 14:39:46 +10:00
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