Commit graph

1293 commits

Author SHA1 Message Date
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
2b55f6111d Merge pull request #1180 from RumovZ/say-blank
Pronounce "[...]" as "blank" with TTS
2021-05-20 18:48:10 +10:00
RumovZ
4595dc5f28 Pronounce "[...]" as "blank" with TTS 2021-05-20 09:42:38 +02:00
Damien Elmes
0a3c727436 add a separate DeckId search for decks with children
- The "unbury deck" option was broken, as it was ignoring child
decks. It would be nice if we could use active_decks instead, but
plugging that into the old scheduler without breaking undo seems a bit
tricky.
- Remove the implicit From impl for decks, so we need to be forced to
think about whether we want child decks or not.
2021-05-20 11:44:37 +10:00
Damien Elmes
60ef1c35eb show note about old options screen if any add-ons are installed 2021-05-19 16:20:25 +10:00
Damien Elmes
79fb17c17f fix accidental schema bump in undo that was forcing full sync 2021-05-19 14:17:49 +10:00
RumovZ
4725fc436f Adjust search syntax for filtered deck presets 2021-05-17 12:14:02 +02:00
Damien Elmes
95a7ceff41 shift learning fuzz into answering stage in test scheduler
When shown on the answer buttons, it's too distracting
2021-05-17 13:05:42 +10:00
RumovZ
e4df61f9aa Preserve formatting of regex error 2021-05-16 21:07:35 +02:00
RumovZ
6024a8748f Remove SearchErrorKind::Regex as it's never used 2021-05-16 21:07:03 +02: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
060ef67b26 remove some duplicate code & add deck.or() helper 2021-05-14 22:35:52 +10:00
Damien Elmes
a42648a418 fix test scheduler undo + implement look-ahead
Instead of using a separate undo queue, the code now defers checking for
newly-due learning cards until the answering stage, and logs the updated
cutoff time as an undoable change, so that any newly-due learning cards
won't appear instead of a new/review card that was just undone.

Queue redo now uses a similar approach to undo, instead of rebuilding the
queues.
2021-05-14 22:16:53 +10:00
Damien Elmes
127b7e28fc drop binary heap in test scheduler
The original rationale was avoiding a possible O(n) insertion if
the learning card was due outside the cutoff, but the increased code
complexity doesn't seem worth it, given that learning cards will
rarely grow above 1000.

Also added a currently-disabled test that demonstrates the current undo
handling behaviour is yielding incorrect counts; that will be reworked
in the next commit, and this change will make that easier.
2021-05-14 16:19:46 +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
9ff8727e68 pass sort options into test scheduler
- split new card fetch order and subsequent sort order; use latter
when building queues
- default to spacing siblings when burying is off, with options to
show each sibling in turn, and shuffle the fetched cards
2021-05-13 15:21:20 +10:00
Damien Elmes
2142cdbd24 fix burying in test scheduler
The bury new/review flags are now pulled from each card's home deck,
instead of using a global setting that had not been hooked up. This
unfortunately means we need to fetch the map of all decks up front, as
we need to be able to look up a deck configuration for cards that are
in filtered decks.

Fixes a "card was modified" error caused by cards being buried during
review, when they weren't removed up-front.
2021-05-12 12:00:15 +10:00
Damien Elmes
5a10f007e7 is_stale() doesn't need to be passed deck
Deck changes will trigger a queue rebuild via requires_study_queue_rebuild()
2021-05-12 09:44:10 +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
75589e3eba better leech tag handling for test scheduler 2021-05-10 14:58:04 +10:00
Damien Elmes
5e44a34f20 expose step counter and undone op changes in hook 2021-05-08 17:51:36 +10:00
Damien Elmes
57fada3be0 move action names out of undo.ftl into actions.ftl 2021-05-08 17:11:54 +10:00
Damien Elmes
f9d5eda3f8 update Rust deps 2021-05-07 18:22:27 +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
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
126d27585f add a valid, empty file so the check action works in Rust Analyzer 2021-05-05 15:53:27 +10:00
Damien Elmes
1802066afe support undo for (renamed) unbury_deck() action 2021-04-30 20:03:20 +10:00
Damien Elmes
994d26937f remove some unneeded transactions from tests 2021-04-30 19:18:02 +10:00
Damien Elmes
65e2bfb16d fix invalid outer transaction in clear_unused_tags() 2021-04-30 19:09:02 +10:00
Damien Elmes
09f3e1db07 empty/restore media trash shouldn't clear undo 2021-04-30 19:07:30 +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
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
df068c2a17 update backend to support undoing of notetype changes 2021-04-30 12:54:59 +10:00
Damien Elmes
03ca227fd4 make it more ergonomic to search directly via nodes in Rust 2021-04-30 11:37:55 +10:00
Damien Elmes
acac1ae1f2 move note/card removal for notetype out of storage layer 2021-04-29 19:44:09 +10:00
Damien Elmes
df42d466b9 make config prefix removal undoable 2021-04-29 19:16:02 +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
Damien Elmes
9c3cf8b25b move pub functions to top of notetype/mod.rs 2021-04-29 15:32:59 +10:00
Damien Elmes
adec449ad4 move pub functions to top of notes/mod.rs 2021-04-29 14:08:15 +10:00
Damien Elmes
4f128aa330 confirm deletion is requiring a full sync 2021-04-28 22:21:16 +10:00
Damien Elmes
4216dd6d7e add some unit tests to deck config updating 2021-04-28 22:00:39 +10:00
Damien Elmes
77038ae554 DeckConfId -> DeckConfigId 2021-04-28 21:09:26 +10:00
Damien Elmes
985d256e7a sort deck on config update; fix id not being updated after deletion 2021-04-28 21:08:09 +10:00
Damien Elmes
deabb30dea report pinned package issues upstream 2021-04-27 23:11:22 +10:00
Damien Elmes
d76ef9cde5 update Rust deps
- tokio 1.0
- updated reqwest, thanks to Rumo
- other minor dep updates

the reqwest build file has been split into two, as it was awkward
to manually update the combined file, and the platform gate is now
on the target in rslib/
2021-04-27 22:18:12 +10:00
Damien Elmes
ddf7c5bb89 update translations 2021-04-25 22:06:05 +10:00
Damien Elmes
a7ef410615 hook new deck config screen up behind an env var 2021-04-22 10:59:16 +10:00
Damien Elmes
592e13e967 deckconf -> deckconfig 2021-04-20 21:54:24 +10:00
Damien Elmes
2fd7e8539d change detection needs to ignore collection mtime bump 2021-04-20 19:52:47 +10:00