add options to v3 to preserve new card gather order

Allows cards to be presented in deck order when gather priority is set
to 'deck'.
This commit is contained in:
Damien Elmes 2021-08-20 12:03:32 +10:00
parent 94a0355389
commit 131c8b72f8
4 changed files with 16 additions and 0 deletions

View file

@ -113,6 +113,8 @@ deck-config-sort-order-card-template-then-random = Card template, then random
deck-config-sort-order-lowest-position = Ascending position deck-config-sort-order-lowest-position = Ascending position
deck-config-sort-order-highest-position = Descending position deck-config-sort-order-highest-position = Descending position
deck-config-sort-order-random = Random deck-config-sort-order-random = Random
deck-config-sort-order-template-then-gather = Card template, then order gathered
deck-config-sort-order-gather = Order gathered
deck-config-new-review-priority = New/review priority deck-config-new-review-priority = New/review priority
deck-config-new-review-priority-tooltip = When to show new cards in relation to review cards. deck-config-new-review-priority-tooltip = When to show new cards in relation to review cards.
deck-config-interday-step-priority = Interday learning/review priority deck-config-interday-step-priority = Interday learning/review priority

View file

@ -43,6 +43,10 @@ message DeckConfig {
NEW_CARD_SORT_ORDER_LOWEST_POSITION = 3; NEW_CARD_SORT_ORDER_LOWEST_POSITION = 3;
NEW_CARD_SORT_ORDER_HIGHEST_POSITION = 4; NEW_CARD_SORT_ORDER_HIGHEST_POSITION = 4;
NEW_CARD_SORT_ORDER_RANDOM = 5; NEW_CARD_SORT_ORDER_RANDOM = 5;
// Sorts by template, preserving original gather order.
NEW_CARD_SORT_ORDER_TEMPLATE_ONLY = 6;
// Preserves original gather order (eg deck order)
NEW_CARD_SORT_ORDER_NO_SORT = 7;
} }
enum ReviewCardOrder { enum ReviewCardOrder {
REVIEW_CARD_ORDER_DAY = 0; REVIEW_CARD_ORDER_DAY = 0;

View file

@ -26,6 +26,14 @@ impl QueueBuilder {
self.new.iter_mut().for_each(NewCard::hash_id_and_mtime); self.new.iter_mut().for_each(NewCard::hash_id_and_mtime);
self.new.sort_unstable_by(new_hash) self.new.sort_unstable_by(new_hash)
} }
NewCardSortOrder::TemplateOnly => {
// stable sort to preserve gather order
self.new
.sort_by(|a, b| a.template_index.cmp(&b.template_index))
}
NewCardSortOrder::NoSort => {
// preserve gather order
}
} }
} }
} }

View file

@ -31,6 +31,8 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
tr.deckConfigSortOrderLowestPosition(), tr.deckConfigSortOrderLowestPosition(),
tr.deckConfigSortOrderHighestPosition(), tr.deckConfigSortOrderHighestPosition(),
tr.deckConfigSortOrderRandom(), tr.deckConfigSortOrderRandom(),
tr.deckConfigSortOrderTemplateThenGather(),
tr.deckConfigSortOrderGather(),
]; ];
const reviewOrderChoices = [ const reviewOrderChoices = [
tr.deckConfigSortOrderDueDateThenRandom(), tr.deckConfigSortOrderDueDateThenRandom(),