diff --git a/crates/app/src/main.rs b/crates/app/src/main.rs index a7a7ac4..abd4983 100644 --- a/crates/app/src/main.rs +++ b/crates/app/src/main.rs @@ -1,12 +1,12 @@ #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] mod champion_table; +mod page; #[cfg(feature = "profile")] mod profile; mod release; mod settings; mod single_instance; -mod stats_page; mod text; mod title_bar; mod tray; @@ -22,8 +22,8 @@ use gpui_kit::base::async_util::{Sender, unbounded}; use gpui_kit::component::*; use gpui_kit::*; +use page::Page; use settings::{KeyEvent, KeyForm, KeyStore, apply_theme}; -use stats_page::StatsPage; use title_bar::{MIN_WINDOW_SIZE, refresh_button, settings_button, title_bar, update_button}; use worker::{Msg, spawn_follower}; @@ -36,7 +36,7 @@ enum Screen { } struct RootView { - page: Entity, + page: Entity, form: Entity, focus: FocusHandle, screen: Screen, @@ -61,7 +61,7 @@ impl RootView { let first_launch = !store.has_key() && tracker.accounts().unwrap_or_default().is_empty(); let (tx, rx) = unbounded(); let page = cx.new(|cx| { - StatsPage::new( + Page::new( tracker.clone(), notice, !first_launch, @@ -92,7 +92,7 @@ impl RootView { let champ_select = cx.subscribe_in( &page, window, - |this, _, transition: &stats_page::ChampSelectTransition, window, cx| { + |this, _, transition: &page::ChampSelectTransition, window, cx| { // Only on entry: the window stays open after the champ select. if transition.entered && let Some(hwnd) = tray::window_hwnd(window) diff --git a/crates/app/src/stats_page.rs b/crates/app/src/page.rs similarity index 99% rename from crates/app/src/stats_page.rs rename to crates/app/src/page.rs index 0ebcc6d..7fa27d8 100644 --- a/crates/app/src/stats_page.rs +++ b/crates/app/src/page.rs @@ -1,4 +1,4 @@ -//! The statistics page: banners, Challenge header, charts and champion table for one Account. +//! The page: banners, Challenge header, charts and champion table for one Account. use std::sync::Arc; use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH}; @@ -87,9 +87,9 @@ impl SelectItem for AccountItem { pub struct ChampSelectTransition { pub entered: bool, } -impl EventEmitter for StatsPage {} +impl EventEmitter for Page {} -pub struct StatsPage { +pub struct Page { tracker: Arc, tx: Sender, notice: Option, @@ -157,7 +157,7 @@ fn filters(in_season: bool) -> &'static [(&'static str, StateFilter)] { } } -impl StatsPage { +impl Page { /// `following`: a follower thread is already running, its first round is pending. pub fn new( tracker: Arc, @@ -259,7 +259,7 @@ impl StatsPage { } }); - let mut page = StatsPage { + let mut page = Page { status: tracker.status(), tracker, tx, @@ -1104,7 +1104,7 @@ fn attempts_chart(charts: &Charts) -> Option { }) } -impl Render for StatsPage { +impl Render for Page { fn render(&mut self, _: &mut Window, cx: &mut Context) -> impl IntoElement { let (border, muted) = { let theme = cx.theme(); @@ -1241,10 +1241,10 @@ mod tests { WindowBounds, WindowOptions, point, px, size, }; - use super::StatsPage; + use super::Page; use crate::champion_table::tests::row; - fn open_page(cx: &mut TestAppContext) -> (Entity, VisualTestContext) { + fn open_page(cx: &mut TestAppContext) -> (Entity, VisualTestContext) { open_page_with_tracker( cx, Tracker::open( @@ -1259,7 +1259,7 @@ mod tests { fn open_page_with_tracker( cx: &mut TestAppContext, tracker: Tracker, - ) -> (Entity, VisualTestContext) { + ) -> (Entity, VisualTestContext) { cx.update(gpui_kit::init); let tracker = Arc::new(tracker); let (window, page) = cx.update(|cx| { @@ -1273,7 +1273,7 @@ mod tests { ..Default::default() }; gpui_kit::open_window(options, cx, |window, cx| { - cx.new(|cx| StatsPage::new(tracker, None, false, rx, tx, window, cx)) + cx.new(|cx| Page::new(tracker, None, false, rx, tx, window, cx)) }) .unwrap() }); @@ -1316,7 +1316,7 @@ mod tests { /// A page on Alice's 3x6 statistics with the Format filter set, whose refresh worker meets Bob /// (the client adopted another Account) before the UI does. - async fn refresh_towards_bob(cx: &mut TestAppContext, pin_alice: bool) -> Entity { + async fn refresh_towards_bob(cx: &mut TestAppContext, pin_alice: bool) -> Entity { cx.executor().allow_parking(); let tracker = Tracker::open(Path::new(":memory:"), Box::new(RefreshHistory)) .unwrap()