Drop the official count note from the « Statistiques » tiles (#143)

The tiles are now all built the same way; the mismatch alert stays the only
signal of an incomplete history.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
nessarandClaude Opus 5.5 committed 2026-11-27 16:22:04 +01:00
1 parent c3003930f1
commit 45adf219d7
5 files changed
+106 -55

No files matched your search

+22 -13
View File
@@ -16,34 +16,43 @@ impl Page {
let mut banners = Vec::new();
if let Some(problem) = &self.status.problem {
let message = problem.message();
banners.push(match problem {
UpdateProblem::MatchPending
| UpdateProblem::RateLimited
| UpdateProblem::NoAccount => Alert::warning("problem", message),
_ => Alert::error("problem", message),
});
banners.push((
"problem",
match problem {
UpdateProblem::MatchPending
| UpdateProblem::RateLimited
| UpdateProblem::NoAccount => Alert::warning("problem", message),
_ => Alert::error("problem", message),
},
));
}
if let Some(error) = self.friend_error() {
banners.push(Alert::error("friend", error.clone()));
banners.push(("friend", Alert::error("friend", error.clone())));
}
if let Some(ProgressCheck::Differs { app, official }) = self.official() {
banners.push(Alert::warning(
banners.push((
"official",
official_differs(*app, *official),
Alert::warning("official", official_differs(*app, *official)),
));
}
if !self.pending_round && !self.status.client_running {
banners.push(Alert::info("client", CLIENT_ABSENT));
banners.push(("client", Alert::info("client", CLIENT_ABSENT)));
}
if let Some(notice) = &self.notice {
banners.push(Alert::warning("notice", notice.clone()));
banners.push(("notice", Alert::warning("notice", notice.clone())));
}
if let Some(error) = self.error() {
banners.push(Alert::error("stats", error.clone()));
banners.push(("stats", Alert::error("stats", error.clone())));
}
banners
.into_iter()
.map(|alert| alert.small().into_any_element())
.map(|(id, alert)| {
// The selector lets the tests find the alert; it costs nothing in a release build.
div()
.debug_selector(move || id.into())
.child(alert.small())
.into_any_element()
})
.collect()
}
+9 -36
View File
@@ -3,7 +3,7 @@
mod data;
use arena_tracker_core::{ChallengeSummary, Charts, ProgressCheck, StateFilter};
use arena_tracker_core::{ChallengeSummary, Charts, StateFilter};
use gpui_kit::component::chart::{AreaChart, BarChart};
use gpui_kit::component::input::Input;
use gpui_kit::component::select::Select;
@@ -13,7 +13,7 @@ use gpui_kit::prelude::FluentBuilder as _;
use gpui_kit::*;
use super::{Page, Tab as Screen, shown};
use crate::text::{decimal, official_note};
use crate::text::decimal;
use crate::theme::{heading, surface};
const NO_MATCH: &str = "Aucune Partie";
@@ -37,13 +37,9 @@ fn filters(in_season: bool) -> &'static [(&'static str, StateFilter)] {
}
}
fn tile(
label: &'static str,
value: String,
note: Option<String>,
theme: &Theme,
) -> impl IntoElement {
fn tile(label: &'static str, value: String, theme: &Theme) -> impl IntoElement {
div()
.debug_selector(move || format!("tile-{label}"))
.v_flex()
.flex_1()
.gap_1()
@@ -64,44 +60,21 @@ fn tile(
.font_weight(FontWeight::SEMIBOLD)
.child(value),
)
.children(note.map(|note| {
div()
.text_xs()
.text_color(theme.muted_foreground)
.child(note)
}))
}
fn challenge_tiles(
c: &ChallengeSummary,
official: Option<&ProgressCheck>,
theme: &Theme,
) -> impl IntoElement {
fn challenge_tiles(c: &ChallengeSummary, theme: &Theme) -> impl IntoElement {
let average = c.average_attempts.map_or("-".into(), |a| decimal(a, 2));
// Next to the count whether the app agrees or not; the banner covers the difference.
let note = match official {
Some(ProgressCheck::Agrees(n)) | Some(ProgressCheck::Differs { official: n, .. }) => {
Some(official_note(*n))
}
_ => None,
};
div()
.h_flex()
.gap_3()
.child(tile(
"Champions validés",
format!("{} / {}", c.completed, c.total),
note,
theme,
))
.child(tile("Tentatives", c.attempts.to_string(), None, theme))
.child(tile("Tentatives par champion validé", average, None, theme))
.child(tile(
"Du premier coup",
c.first_tries.to_string(),
None,
theme,
))
.child(tile("Tentatives", c.attempts.to_string(), theme))
.child(tile("Tentatives par champion validé", average, theme))
.child(tile("Du premier coup", c.first_tries.to_string(), theme))
}
/// A titled card holding a chart, or `empty` in its place.
@@ -353,7 +326,7 @@ impl Page {
if shown("tiles")
&& let Some(c) = challenge
{
content.push(challenge_tiles(c, self.official(), cx.theme()).into_any_element());
content.push(challenge_tiles(c, cx.theme()).into_any_element());
}
content.push(
self.charts
+1
View File
@@ -42,3 +42,4 @@ mod portraits;
mod ring_hover;
mod sorting;
mod sorting_fixtures;
mod statistics_tiles;
@@ -0,0 +1,74 @@
//! The « Statistiques » tiles never carry the official count (#143): only the mismatch alert
//! shows what the game counts.
use super::page_fixtures::{draw, open_page_in_season, show, statistics, switch_tab};
use crate::page::{Page, Tab};
use crate::worker::Msg;
use arena_tracker_core::{Account, ProgressCheck, Status};
use gpui_kit::{Entity, TestAppContext, VisualTestContext};
/// The page on Alice's Challenge in the current Season, with `official` as the game's count.
fn with_official(page: &Entity<Page>, cx: &mut VisualTestContext, official: ProgressCheck) {
cx.update(|window, cx| {
page.update(cx, |page, cx| {
let status = Status {
updating: Some(Account {
puuid: "p".into(),
game_name: "Alice".into(),
tag_line: "EUW".into(),
}),
official_progress: official,
..page.status.clone()
};
page.apply(
Msg::Round {
status,
reload: false,
matches: Vec::new(),
game_end: None,
},
window,
cx,
)
})
});
}
/// The drawn height of the tile `label`, once the page is drawn again.
fn tile_height(window: &mut VisualTestContext, label: &'static str) -> f32 {
draw(window);
let bounds = window.debug_bounds(label).expect("the tile is drawn");
bounds.size.height.into()
}
#[gpui::test]
async fn the_tiles_stay_without_the_official_count(cx: &mut TestAppContext) {
cx.executor().allow_parking();
let (page, mut window) = open_page_in_season(cx);
cx.condition(&page, |p, _| !p.busy()).await;
show(&page, &mut window, statistics(52, 100, Vec::new()));
switch_tab(&page, &mut window, Tab::Statistics);
// Without the game's count, the row of tiles has its own height. The row stretches to its
// tallest tile, so a note under the first tile would make every tile taller.
let plain = tile_height(&mut window, "tile-Champions validés");
assert_eq!(tile_height(&mut window, "tile-Tentatives"), plain);
// The game agrees: no alert, and the tiles are as tall as without the count.
with_official(&page, &mut window, ProgressCheck::Agrees(52));
assert_eq!(tile_height(&mut window, "tile-Champions validés"), plain);
assert_eq!(tile_height(&mut window, "tile-Tentatives"), plain);
assert!(window.debug_bounds("official").is_none());
// The game differs: the alert still shows, and the tiles are as tall as before.
with_official(
&page,
&mut window,
ProgressCheck::Differs {
app: 50,
official: 52,
},
);
assert_eq!(tile_height(&mut window, "tile-Champions validés"), plain);
assert_eq!(tile_height(&mut window, "tile-Tentatives"), plain);
assert!(window.debug_bounds("official").is_some());
}
-6
View File
@@ -98,11 +98,6 @@ pub const CLIENT_ABSENT: &str =
"Client League of Legends non détecté : affichage des données enregistrées.";
const INTERNAL_ERROR: &str = "Mise à jour impossible : erreur interne.";
/// The discreet line under the Challenge tile.
pub fn official_note(official: u32) -> String {
format!("Progression officielle : {official}")
}
pub fn official_differs(app: usize, official: u32) -> String {
format!(
"La Progression officielle du jeu indique {official} champions validés, l'application en compte {app} : des Parties manquent peut-être."
@@ -220,7 +215,6 @@ mod tests {
#[test]
fn official_progress_texts() {
assert_eq!(official_note(52), "Progression officielle : 52");
assert_eq!(
official_differs(50, 52),
"La Progression officielle du jeu indique 52 champions validés, l'application en compte 50 : des Parties manquent peut-être."