Sort the cards by Mastery Points or A to Z and remember the choice (#76)
The statistics rows carry the Mastery Points: None for an Account whose points were never fetched, Some(0) for a champion missing from the last list. One card order, computed only when the statistics or the preference change, feeds the home grid, the Anvil row and « Autres champions ». The sort selector stays visible during a champ select, the choice is saved with the other preferences, and the sheet shows the Mastery Points (unknown ones after the known, and not as zero). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
815daf33cb
commit
a457a19fe5
11 files changed
+857
-55
No files matched your search
+32
-1
@@ -8,7 +8,7 @@ use gpui_kit::component::{ActiveTheme as _, Icon, IconName, StyledExt as _};
|
||||
use gpui_kit::prelude::FluentBuilder as _;
|
||||
use gpui_kit::*;
|
||||
|
||||
use crate::text::ordinal;
|
||||
use crate::text::{ordinal, thousands};
|
||||
|
||||
/// Width over height.
|
||||
pub const ASPECT: f32 = 0.68;
|
||||
@@ -33,6 +33,8 @@ const PLAYED: &str = "Parties";
|
||||
const WINS: &str = "Victoires";
|
||||
const BEST_PLACEMENT: &str = "Meilleur Placement";
|
||||
const ATTEMPTS: &str = "Tentatives";
|
||||
const MASTERY: &str = "Points de maîtrise";
|
||||
const UNKNOWN: &str = "Inconnus";
|
||||
/// Only on a Completed champion.
|
||||
pub const FIRST_TOP_1: &str = "Premier top 1";
|
||||
const NONE: &str = "—";
|
||||
@@ -158,6 +160,12 @@ fn sheet_lines(row: &ChampionRow) -> Vec<(&'static str, SharedString)> {
|
||||
.map_or_else(|| NONE.into(), |placement| ordinal(placement).into()),
|
||||
),
|
||||
(ATTEMPTS, count(row.attempts)),
|
||||
// Unknown is not zero: the points were never fetched for this Account.
|
||||
(
|
||||
MASTERY,
|
||||
row.mastery_points
|
||||
.map_or_else(|| UNKNOWN.into(), |points| thousands(points).into()),
|
||||
),
|
||||
];
|
||||
if let Some(date) = challenge.and_then(|c| c.completed_on) {
|
||||
lines.push((FIRST_TOP_1, date.to_string().into()));
|
||||
@@ -379,6 +387,7 @@ mod tests {
|
||||
attempts: None,
|
||||
state: None,
|
||||
challenge,
|
||||
mastery_points: Some(154_320),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -462,6 +471,7 @@ mod tests {
|
||||
("Victoires", "0".into()),
|
||||
("Meilleur Placement", "—".into()),
|
||||
("Tentatives", "0".into()),
|
||||
("Points de maîtrise", "154\u{202f}320".into()),
|
||||
]
|
||||
);
|
||||
}
|
||||
@@ -484,6 +494,7 @@ mod tests {
|
||||
("Victoires", "2".into()),
|
||||
("Meilleur Placement", "2ᵉ".into()),
|
||||
("Tentatives", "5".into()),
|
||||
("Points de maîtrise", "154\u{202f}320".into()),
|
||||
]
|
||||
);
|
||||
assert!(card.sheet.iter().all(|(label, _)| *label != FIRST_TOP_1));
|
||||
@@ -506,6 +517,7 @@ mod tests {
|
||||
("Victoires", "3".into()),
|
||||
("Meilleur Placement", "1ᵉʳ".into()),
|
||||
("Tentatives", "4".into()),
|
||||
("Points de maîtrise", "154\u{202f}320".into()),
|
||||
("Premier top 1", "02/03/2026".into()),
|
||||
]
|
||||
);
|
||||
@@ -521,10 +533,29 @@ mod tests {
|
||||
("Victoires", "—".into()),
|
||||
("Meilleur Placement", "—".into()),
|
||||
("Tentatives", "—".into()),
|
||||
("Points de maîtrise", "154\u{202f}320".into()),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_sheet_shows_zero_points_as_zero_and_unknown_points_as_unknown() {
|
||||
let mut row = row(None);
|
||||
row.mastery_points = Some(0);
|
||||
let card = Card::from_row(&row);
|
||||
assert_eq!(
|
||||
lines(&card).last().unwrap(),
|
||||
&("Points de maîtrise", "0".to_string())
|
||||
);
|
||||
|
||||
row.mastery_points = None;
|
||||
let card = Card::from_row(&row);
|
||||
assert_eq!(
|
||||
lines(&card).last().unwrap(),
|
||||
&("Points de maîtrise", "Inconnus".to_string())
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_row_without_a_challenge_has_no_marks() {
|
||||
let card = Card::from_row(&row(None));
|
||||
|
||||
Reference in new issue
Block a user