Anki/rslib/src/scheduler/queue
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
..
builder deckconf -> deckconfig 2021-04-20 21:54:24 +10:00
entry.rs tidy up Rust imports 2021-04-18 18:38:54 +10:00
learning.rs switch next_day_at to a newtype 2021-04-05 16:17:26 +10:00
limits.rs DeckConfId -> DeckConfigId 2021-04-28 21:09:26 +10:00
main.rs use mixed case for abbreviations in Rust code 2021-03-27 19:53:33 +10:00
mod.rs add support for custom undo steps, and merging multiple actions 2021-05-06 16:39:06 +10:00
undo.rs use mixed case for abbreviations in Rust code 2021-03-27 19:53:33 +10:00