Ping line opens connection stats too
Browse files at this commit1b3b5a4256edbc55ec6f15ff36fcf6e055d6223dParent: 89a7c6e- feat
- ping line opens connection stats too
- the call bar sheet shows only connection and traffic, full detail stays in the header stats
5 changed files +35 -1
- crates/client/src/gui/builder/overview.rs +1 -0
- crates/client/src/gui/builder/users.rs +1 -0
- crates/client/src/gui/call_bar.rs +7 -0
- crates/client/src/gui/chat.rs +4 -0
- crates/client/src/gui/voice_stats.rs +22 -1
crates/client/src/gui/builder/overview.rsmodified+1 -0
| @@ -218,6 +218,7 @@ impl Yumush { | |||
| 218 | .child(div().p(px(space::LG)).child(voice_stats::stats_panel( | 218 | .child(div().p(px(space::LG)).child(voice_stats::stats_panel( |
| 219 | stats, | 219 | stats, |
| 220 | &|id| self.chat.name_of(id), | 220 | &|id| self.chat.name_of(id), |
| 221 | + voice_stats::Detail::Full, | ||
| 221 | palette, | 222 | palette, |
| 222 | ))), | 223 | ))), |
| 223 | ); | 224 | ); |
crates/client/src/gui/builder/users.rsmodified+1 -0
| @@ -1058,6 +1058,7 @@ impl Yumush { | |||
| 1058 | super::super::voice_stats::stats_panel( | 1058 | super::super::voice_stats::stats_panel( |
| 1059 | stats, | 1059 | stats, |
| 1060 | &|id| self.chat.name_of(id), | 1060 | &|id| self.chat.name_of(id), |
| 1061 | + super::super::voice_stats::Detail::Full, | ||
| 1061 | palette, | 1062 | palette, |
| 1062 | ) | 1063 | ) |
| 1063 | .pt(px(space::MD)) | 1064 | .pt(px(space::MD)) |
crates/client/src/gui/call_bar.rsmodified+7 -0
| @@ -180,9 +180,16 @@ pub fn view(bar: CallBar, actions: CallActions, t: Tokens) -> Div { | |||
| 180 | ) | 180 | ) |
| 181 | .child( | 181 | .child( |
| 182 | div() | 182 | div() |
| 183 | + .id("bar_ping_line") | ||
| 183 | .flex_none() | 184 | .flex_none() |
| 184 | .w(px(size::ROW)) | 185 | .w(px(size::ROW)) |
| 185 | .h(px(size::ICON)) | 186 | .h(px(size::ICON)) |
| 187 | + .cursor_pointer() | ||
| 188 | + .tip("Connection stats") | ||
| 189 | + .on_click({ | ||
| 190 | + let stats = run(&actions.stats); | ||
| 191 | + move |_, window, cx| stats(window, cx) | ||
| 192 | + }) | ||
| 186 | .child(super::parts::spark( | 193 | .child(super::parts::spark( |
| 187 | pings, | 194 | pings, |
| 188 | super::voice_stats::SAMPLE_HISTORY, | 195 | super::voice_stats::SAMPLE_HISTORY, |
crates/client/src/gui/chat.rsmodified+4 -0
| @@ -1450,6 +1450,10 @@ impl Yumush { | |||
| 1450 | .child(voice_stats::stats_panel( | 1450 | .child(voice_stats::stats_panel( |
| 1451 | &self.chat.stats, | 1451 | &self.chat.stats, |
| 1452 | &|id| self.chat.name_of(id), | 1452 | &|id| self.chat.name_of(id), |
| 1453 | + match at { | ||
| 1454 | + StatsAt::Header => voice_stats::Detail::Full, | ||
| 1455 | + StatsAt::Dock => voice_stats::Detail::Connection, | ||
| 1456 | + }, | ||
| 1453 | palette, | 1457 | palette, |
| 1454 | )), | 1458 | )), |
| 1455 | ) | 1459 | ) |
crates/client/src/gui/voice_stats.rsmodified+22 -1
| @@ -79,9 +79,30 @@ pub fn quality(samples: &VecDeque<VoiceSample>) -> Option<Quality> { | |||
| 79 | samples.back().map(Quality::of) | 79 | samples.back().map(Quality::of) |
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | -pub fn stats_panel(stats: &Stats, name: &dyn Fn(Id) -> String, palette: Palette) -> Div { | 82 | +#[derive(Clone, Copy, PartialEq, Eq)] |
| 83 | +pub enum Detail { | ||
| 84 | + Connection, | ||
| 85 | + Full, | ||
| 86 | +} | ||
| 87 | + | ||
| 88 | +pub fn stats_panel( | ||
| 89 | + stats: &Stats, | ||
| 90 | + name: &dyn Fn(Id) -> String, | ||
| 91 | + detail: Detail, | ||
| 92 | + palette: Palette, | ||
| 93 | +) -> Div { | ||
| 83 | let t = palette.tokens; | 94 | let t = palette.tokens; |
| 84 | let share = &stats.share; | 95 | let share = &stats.share; |
| 96 | + if detail == Detail::Connection { | ||
| 97 | + return stack(space::XL) | ||
| 98 | + .w(px(COLUMN_W)) | ||
| 99 | + .when(!stats.voice.is_empty(), |column| { | ||
| 100 | + column.child(connection(stats, t)) | ||
| 101 | + }) | ||
| 102 | + .when(!stats.traffic.is_empty(), |column| { | ||
| 103 | + column.child(traffic(stats, t)) | ||
| 104 | + }); | ||
| 105 | + } | ||
| 85 | band(space::XXL) | 106 | band(space::XXL) |
| 86 | .items_start() | 107 | .items_start() |
| 87 | .flex_wrap() | 108 | .flex_wrap() |