Commit graph

1269 commits

Author SHA1 Message Date
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
Damien Elmes
293cbfb024 check if deck changed before saving 2021-04-20 19:50:31 +10:00
Damien Elmes
05f75c6194 implement deck config updating 2021-04-20 14:57:44 +10:00
Damien Elmes
4eaddde127 remove some imports duplicated by prelude 2021-04-19 18:22:43 +10:00
Damien Elmes
e287ebe988 Merge pull request #1138 from RumovZ/introduced
Add search keyword for "first review in x days"
2021-04-19 18:22:15 +10:00
RumovZ
d4d48676ad Use arg name instead of repeating it in format!() 2021-04-19 08:58:33 +02:00
RumovZ
af1111a91e Use timestamp adding for writing cutoff 2021-04-19 08:44:13 +02:00
RumovZ
e1e25d2b6a Add sql condition for speedup in write_introduced 2021-04-19 08:43:32 +02:00
RumovZ
eb9fbb9c0f Add sidebar filter "first review today" 2021-04-18 13:27:10 +02:00
RumovZ
f514697a90 Add sqlwriter test for introduced 2021-04-18 12:32:02 +02:00
RumovZ
6cfccf63bd Add cutoff_in_secs_from_days() helper method 2021-04-18 12:25:44 +02:00
RumovZ
27b658fc02 Add search keyword introduced
Filters for cards that had their first review within the last x days.
2021-04-18 12:14:18 +02:00
Damien Elmes
363a843d07 tidy up Rust imports
rustfmt can do this automatically, but only when run with a nightly
toolchain, so it needs to be manually done for now - see rslib/rusfmt.toml
2021-04-18 18:38:54 +10:00
Damien Elmes
06dea7aa0a start on making deck config and schema/mod changes undoable
+ move timestamps into a struct in a separate file for convenience
2021-04-18 17:33:12 +10:00
Damien Elmes
1f0ff0f22d add schema change prompt to removal, tweak return struct 2021-04-18 17:33:12 +10:00
RumovZ
6b5a73d3e7 Maybe normalize name when preparing deck update 2021-04-18 09:16:43 +02:00
RumovZ
6864cdb62e Remove redundant imports 2021-04-18 08:43:46 +02:00
Damien Elmes
6eb28909da as_str() -> as_native_str() 2021-04-18 09:33:39 +10:00
Damien Elmes
eece6125d8 hide NativeName inner value, and require explicit accessors 2021-04-18 09:29:35 +10:00
Damien Elmes
e0cf897104 create_missing_parents() can take a native name directly 2021-04-18 09:20:23 +10:00
RumovZ
32edd2b554 Give deck.name the newtype NativeDeckName
The deck name must be constructed by calling associated functions of
NativeDeckName, unless the name is guaranteed to be valid machine
name (like "Default").
NativeDeckName exposes methods to mutate the deck name and return
the human name.
The storage routines take &strs, but those should be slices of
NativeDeckNames to ensure machine form and normalization.
2021-04-17 22:47:04 +02:00
Damien Elmes
cd1c4d0941 Merge pull request #1132 from RumovZ/refactor-decks
Refactor decks/mod.rs
2021-04-17 18:21:56 +10:00
Damien Elmes
0645cb29b7 fix parent limit handling
We can't calculate it on the backend, as adjusting a config may alter
the parent limit.

Also fix hidden deck name and missing separator.
2021-04-17 12:53:59 +10:00
RumovZ
bca111e6b5 Split Col impls in decks in pub and private blocks 2021-04-16 08:30:16 +02:00
RumovZ
6a974a49bb Remove some imports in decks which are in prelude 2021-04-15 20:07:16 +02:00