Commit graph

974 commits

Author SHA1 Message Date
Damien Elmes
52a98ce0ce change get_queued_cards() to no longer return congrats info 2021-05-26 12:59:45 +10:00
Damien Elmes
22b05be570 expose the ability to get/set aux notetype/template keys
template keys are not currently adjusted when card templates are
repositioned.
2021-05-25 22:13:53 +10:00
Damien Elmes
691a5c5c44 pass css and latex svg flag back from rendering op
This could potentially help us avoid having to refetch the notetype
during study in the future, though updates to Note initialization and
the LaTeX handling would be required first.
2021-05-25 18:41:43 +10:00
Damien Elmes
12b4080dd3 support passing in a native notetype object to render_uncommitted_card() 2021-05-25 16:58:06 +10:00
Damien Elmes
9fed62c6a4 prevent models.setCurrent() clearing the undo queue 2021-05-24 14:54:31 +10:00
Damien Elmes
1f7118a8e3 config updates by the frontend now skip undo by default 2021-05-24 14:50:46 +10:00
abdo
9cbbdc1270 Fix wrong stock note type being used
https://forums.ankiweb.net/t/anki-2-1-45-alpha/10061/49
2021-05-23 07:56:59 +03:00
Damien Elmes
5427668303 expose undoable config changes to frontend; refresh sidebar
The browser header handling still needs updating
2021-05-21 17:50:41 +10:00
Damien Elmes
ba727735bd report changed cards when changing deck/flag
+ fix repeated flag shortcut not toggling
2021-05-21 16:03:05 +10:00
Damien Elmes
2b2689f630 add v3 scheduler to col.sched type union
Will allow us to catch issues like the custom study one in the future
2021-05-19 16:06:52 +10:00
Damien Elmes
af90dd5d45 fix custom study in v3 scheduler 2021-05-19 15:58:18 +10:00
Damien Elmes
91931ed7a7 compat fixes for add-on usage of col.decks.active() 2021-05-19 15:41:37 +10:00
Damien Elmes
0767754ca6 enable redo support
Also:

- fix issues where the Undo action in the Browse screen was not
consistent with the main window. The existing hook signature has been
changed; from a snapshot of the add-on code from a few months ago, it
was not a hook that was being used by anyone.
- change the undo shortcut in the Browse window to match the main
window. It was different because undoing a change in the editing area
could accidentally trigger an undo of an operation, but the damage is
limited now that (most) operations can be redone. If it still proves to
be a problem, perhaps we should just always swallow ctrl+z when an
editing field is focused.
2021-05-19 15:18:39 +10:00
RumovZ
f220165c0f Fix black workaround for format calls 2021-05-18 22:19:09 +02:00
Damien Elmes
376ec09d1a add legacy NoteType alias
https://github.com/johnpincock/SpecialFields/issues/28
2021-05-18 09:18:46 +10:00
Damien Elmes
fe5dee2a67 rework various aspects of the test scheduler
- Daily limits are no longer inherited - each deck limits its own
cards, and the selected deck enforces a maximum limit.
- Fetching of review cards now uses a single query, and sorts in advance.
In collections with a large number of overdue cards and decks, this is
faster than iterating over each deck in turn.
- Include interday learning count in review count & review limit, and
allow them to be buried.
- Warn when parent review limit is lower than child deck in deck options.
- Cap the new card limit to the review limit.
- Add option to control whether new card fetching short-circuits.
2021-05-16 20:23:07 +10:00
Damien Elmes
78b431cbf1 work around Windows issue on latest Black
Thanks Rumo!
552a53495e
2021-05-13 20:15:51 +10:00
Damien Elmes
5f7590c4b4 expose new sorting options in test scheduler options; move things around 2021-05-13 15:23:16 +10:00
Damien Elmes
7e324a6ec0 use new API for test scheduler
Avoids duplicate work, and is a step towards allowing the next
states to be modified by third-party code.

Also:

- fixed incorrect underlined count, due to reviews being labeled as
learning cards
- fixed reviewer not refreshing when undoing a test review, by splitting
up backend queue rebuilding from frontend reviewer refresh
- moved answering into a CollectionOp
2021-05-11 13:06:03 +10:00
Damien Elmes
6f3225fb2a drop leech hook in test scheduler
The explicit flush was clearing undo history, and the hook will need
re-working to support propagating OpChanges correctly. It will likely
come back as a GUI hook, instead of one in pylib.
2021-05-10 16:18:29 +10:00
Damien Elmes
eb0a60b539 ensure v2 scheduler before test scheduler enabled 2021-05-10 14:57:30 +10:00
Damien Elmes
2e312eb13d update find_duplicates to use QueryOp/CollectionOp 2021-05-08 16:58:18 +10:00
Damien Elmes
26e9fba1f7 update docstrings for latest black 2021-05-07 18:12:56 +10:00
Damien Elmes
2a6cd2ff72 default to the v2 scheduler in new collections
ported from 9e91785d98
2021-05-06 19:09:28 +10:00
Damien Elmes
42dd2350d0 don't throw an error when an invalid sort order is provided 2021-05-06 17:00:58 +10:00
Damien Elmes
7f7dd7b6c9 add support for custom undo steps, and merging multiple actions
Allows add-on authors to define their own label for a group of undoable
operations. For example:

def mark_and_bury(
    *,
    parent: QWidget,
    card_id: CardId,
) -> CollectionOp[OpChanges]:
    def op(col: Collection) -> OpChanges:
        target = col.add_custom_undo_entry("Mark and Bury")
        col.sched.bury_cards([card_id])
        card = col.get_card(card_id)
        col.tags.bulk_add(note_ids=[card.nid], tags="marked")
        return col.merge_undo_entries(target)

    return CollectionOp(parent, op)

The .add_custom_undo_entry() is for adding your own custom actions.
When extending a standard Anki action, instead store `target = 
col.undo_status().last_step` after executing the standard operation.

This started out as a bigger refactor that required a separate
.commit_undoable() call to be run after each operation, instead of
having each operation return changes directly. But that proved to be
somewhat cumbersome in unit tests, and ran the risk of unexpected
behaviour if the caller invoked an operation without remembering to
finalize it.
2021-05-06 16:39:06 +10:00
Damien Elmes
1802066afe support undo for (renamed) unbury_deck() action 2021-04-30 20:03:20 +10:00
Damien Elmes
e161b9049a undoing of notetype fields
- fix stale cache issue
- update add cards screen in response to op changes
2021-04-30 17:15:59 +10:00
Damien Elmes
46bcfa00fd notetype removal undoable 2021-04-30 16:01:47 +10:00
Damien Elmes
8a9796ee5a update GUI to allow notetype addition undo
- backend now updates current notetype as part of addition
- frontend no longer implicitly adds, so we can assign a new name and
add in a single operation
2021-04-30 15:58:08 +10:00
Damien Elmes
b3d3768baa use aux var when retrieving last deck for notetype
The adding case was already covered by defaults_for_adding(), but we
the code was using the old variable when adding new cards to an existing
note.
2021-04-29 19:15:27 +10:00
rgreenblatt
66c28ebb8f solve missing escape of ' (fixes #1144) 2021-04-22 00:54:11 -04:00
Damien Elmes
48fc9251bd implement deck config saving on JS end 2021-04-20 19:50:05 +10:00
Damien Elmes
1f0ff0f22d add schema change prompt to removal, tweak return struct 2021-04-18 17:33:12 +10:00
Damien Elmes
57a1651113 deck config prototype work in progress
Still in the early stages, and not hooked up yet.
2021-04-14 22:33:10 +10:00
Damien Elmes
2a43d42323 run black/isort on Python scripts 2021-04-14 18:22:02 +10:00
Damien Elmes
77c0f0effd add missing copyright headers to *.rs 2021-04-13 18:59:16 +10:00
Damien Elmes
926fc2e492 add missing copyright headers to *.py 2021-04-13 18:45:35 +10:00
RumovZ
d58af0dd95 Merge branch 'master' into backend-columns 2021-04-11 11:18:15 +02:00
RumovZ
531e08a711 Remove from_config variant in pb SortOrder
Instead, fetch the config order on the frontend and pass a builtin
variant into the backend.
That makes the following unnecessary:
* Resolving the config sort in search/mod.rs
* Deserializing the Column enum
* Config accessors for the sort columns
2021-04-10 11:13:42 +02:00
RumovZ
94d52de9da Store active browser columns in col state 2021-04-09 22:53:02 +02:00
RumovZ
3b23248983 Remove pb SortKind enum and use pb Columns instead 2021-04-09 18:50:30 +02:00
RumovZ
93c6e258aa Merge SortKind enum into Column enum 2021-04-09 18:03:29 +02:00
RumovZ
e28f2320b8 Unify state columns
* Remove duplicate backend columns
* Remove duplicate column routines
* Move columns on frontend from state to model
* Generate available columns from Colum enum
* Add second column label for notes mode
2021-04-08 23:48:24 +02:00
RumovZ
8c499ed5bf Rename columns for future mode-independent use 2021-04-08 23:43:48 +02:00
RumovZ
d7e0da3786 Remove Column class and use pb class instead 2021-04-08 11:17:25 +02:00
RumovZ
7ea1dbd4a4 Move BrowserColumn into BrowserColumns message 2021-04-08 10:16:06 +02:00
RumovZ
3c84749973 Use backend column objects on frontend 2021-04-06 19:47:03 +02:00
Damien Elmes
ae7a327cae current deck change is now undoable
- make sure we set flag in changes when config var changed
- move current deck get/set into backend
- set_config() now returns a bool indicating whether a change was
made, so other operations can be gated off it
- active decks generation is deferred until sched.reset()
2021-04-06 21:52:06 +10:00
Damien Elmes
1b81653e0e update scheduling ops
- migrate to CollectionOp()
- return actual change count when suspending/burying
- add helper to convert vec to vec of newtype
2021-04-06 16:38:42 +10:00