voelin-ui: lay the server screens out as the design mockups do

The screens were built before the mockups were at hand and guessed at
their layout: a strip of voice controls over the chat, pins and topics
floating over the messages, the voice channel as a grid of tiles and a
members panel of our channel only. The mockups put them elsewhere.

- The members panel lists everyone on the server, "Members — N" with a
  search: those streaming (or, in the voice channel and while watching,
  the people in our channel) first, then each server group in the
  server's order, people elsewhere with the channel they are in, and
  moderator groups as a role next to the name.
- Pinned messages and topics take the members panel's place, as cards;
  topics can be searched and show when they were last active, and the
  chat header opens them with labelled buttons.
- The voice channel view is a header with Voice Settings and Leave, the
  people as large avatars with talking and muted marks, the streams as
  large cards (with the picture while we watch) and the channel's chat.
- The chat drops the extra voice strip (the sidebar has the controls);
  messages are larger, times read "Today at 10:14", reactions end with
  an add button, and the composer has a round attach button.
- Hold-to-talk shows only with push-to-talk.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
selikhovandClaude Opus 5.5 committed 2026-10-03 02:23:00 +03:00
1 parent 7994c0212b
commit 6dfd501560
20 files changed
+1196 -666

No files matched your search

+15
View File
@@ -282,6 +282,7 @@ pub(crate) struct Models {
pub servers: Rc<VecModel<ServerItem>>,
pub tree: Rc<VecModel<TreeItem>>,
pub members: Rc<VecModel<MemberItem>>,
pub server_members: Rc<VecModel<MemberItem>>,
pub tabs: Rc<VecModel<ChatTab>>,
pub streams: Rc<VecModel<StreamItem>>,
pub viewers: Rc<VecModel<ViewerItem>>,
@@ -300,6 +301,7 @@ impl Models {
servers: Rc::default(),
tree: Rc::default(),
members: Rc::default(),
server_members: Rc::default(),
tabs: Rc::default(),
streams: Rc::default(),
viewers: Rc::default(),
@@ -312,6 +314,7 @@ impl Models {
bridge.set_servers(ModelRc::from(models.servers.clone()));
bridge.set_tree(ModelRc::from(models.tree.clone()));
bridge.set_members(ModelRc::from(models.members.clone()));
bridge.set_server_members(ModelRc::from(models.server_members.clone()));
bridge.set_tabs(ModelRc::from(models.tabs.clone()));
bridge.set_streams(ModelRc::from(models.streams.clone()));
bridge.set_share_viewers(ModelRc::from(models.viewers.clone()));
@@ -337,6 +340,13 @@ pub(crate) struct App {
pub status: String,
/// The top bar's search: filters the channel tree.
pub tree_filter: String,
/// The members panel's search.
pub member_filter: String,
/// The topics drawer's search.
pub topic_filter: String,
/// The voice channel view is shown (its people come first in the
/// members panel).
pub voice_view: bool,
/// The settings service (shared with the engine); `settings`, `audio`
/// and `playback` are working copies of its keys.
pub prefs: Settings,
@@ -544,6 +554,9 @@ pub fn run(options: RunOptions) -> Result<()> {
models,
status: String::new(),
tree_filter: String::new(),
member_filter: String::new(),
topic_filter: String::new(),
voice_view: false,
prefs,
settings,
audio,
@@ -801,6 +814,8 @@ impl App {
Event::Groups { session, server_groups, .. } => {
let view = self.sessions.entry(session as i64).or_default();
view.server_groups = (*server_groups).clone();
// Display order, as TeamSpeak sorts them.
view.server_groups.sort_by_key(|g| (g.sort_id, g.id));
if self.current == Some(session as i64) {
self.refresh_tree();
}
+3
View File
@@ -7,6 +7,9 @@ use crate::app::{App, Bridge, MainWindow, with_app};
pub(super) fn wire(ui: &MainWindow) {
let bridge = ui.global::<Bridge>();
bridge.on_search_topics(|text| {
with_app(|app| app.search_topics(text.to_string()));
});
bridge.on_open_channel_chat(|cid| {
with_app(|app| app.open_chat(ChatTarget::Channel(cid as ChannelId), true));
});
+6
View File
@@ -14,6 +14,12 @@ pub(super) fn wire(ui: &MainWindow) {
bridge.on_search(|text| {
with_app(|app| app.search(text.to_string()));
});
bridge.on_search_members(|text| {
with_app(|app| app.search_members(text.to_string()));
});
bridge.on_show_voice_view(|on| {
with_app(|app| app.show_voice_view(on));
});
bridge.on_connect_voice(|| {
with_app(|app| app.connect_voice());
});
+16 -9
View File
@@ -55,12 +55,6 @@ fn ago(ts_ms: i64) -> String {
}
}
fn time_of(ts_ms: i64) -> String {
chrono::DateTime::from_timestamp_millis(ts_ms)
.map(|t| t.with_timezone(&chrono::Local).format("%H:%M").to_string())
.unwrap_or_default()
}
impl App {
pub(crate) fn open_chat(&mut self, target: ChatTarget, focus: bool) {
let Some(id) = self.current else { return };
@@ -396,25 +390,30 @@ impl App {
};
PinItem {
line: vm::chat::history_line(&p.message, None, &ctx),
by: format!("pinned by {} · {}", p.by, time_of(p.ts_ms)).into(),
by: format!("Pinned by {} · {}", p.by, vm::chat::time_of(p.ts_ms)).into(),
}
})
.collect();
vm::list::sync(&self.models.pins, &pins);
let filter = self.topic_filter.trim().to_lowercase();
let now = chrono::Utc::now().timestamp_millis();
let topics: Vec<crate::app::TopicItem> = tab
.topics
.iter()
.filter(|t| filter.is_empty() || t.title.to_lowercase().contains(&filter))
.map(|t| crate::app::TopicItem {
id: t.id as i32,
title: t.title.clone().into(),
creator: t.creator.name.clone().into(),
detail: format!(
"{} {} · {}",
"{} {} · by {}",
t.message_count,
if t.message_count == 1 { "message" } else { "messages" },
ago(t.last_activity_ms)
t.creator.name
)
.into(),
activity: format!("Last active {}", ago(t.last_activity_ms)).into(),
recent: now - t.last_activity_ms < 3_600_000,
archived: t.archived,
})
.collect();
@@ -553,6 +552,14 @@ impl App {
self.refresh_chat();
}
/// The topics drawer's search.
pub(crate) fn search_topics(&mut self, text: String) {
if self.topic_filter != text {
self.topic_filter = text;
self.refresh_chat();
}
}
pub(crate) fn open_topics(&mut self) {
let Some(view) = self.view() else { return };
let tab = &view.tabs[view.current_tab];
+1 -1
View File
@@ -145,7 +145,7 @@ pub(crate) fn start(ui: &MainWindow, switches: &Switches) -> Running {
"panel" => nav.set_right_panel_open(true),
"no-panel" => nav.set_right_panel_open(false),
"tab" => nav.set_mobile_tab(mobile_tab(arg)),
"voice" => nav.set_voice_grid(true),
"voice" => nav.invoke_show_voice(true),
"pins" => nav.invoke_show_pins(true),
"topics" => nav.invoke_show_topics(true),
"topic" => {
+44 -11
View File
@@ -226,11 +226,15 @@ impl App {
.into(),
);
bridge.set_nickname(bookmark.map(|b| b.nickname.clone()).unwrap_or_default().into());
let own_channel = view
.and_then(|v| state.own_channel.and_then(|c| v.presence.channels.get(&c)))
.map(|c| c.name.clone())
.unwrap_or_default();
bridge.set_own_channel(own_channel.into());
let own_channel =
view.and_then(|v| state.own_channel.and_then(|c| v.presence.channels.get(&c)));
bridge.set_own_channel(own_channel.map(|c| c.name.clone()).unwrap_or_default().into());
bridge.set_own_channel_topic(
own_channel.and_then(|c| c.topic.clone()).unwrap_or_default().into(),
);
bridge.set_own_channel_limit(
own_channel.and_then(|c| c.max_clients).filter(|m| *m >= 0).unwrap_or(-1),
);
bridge.set_voice_connected(state.voice == VoiceState::Connected);
bridge.set_voice_connecting(state.voice == VoiceState::Connecting);
bridge.set_observing(state.observe != ObserveState::Off);
@@ -255,11 +259,13 @@ impl App {
}
}
/// The channel tree and the members of our channel.
/// The channel tree, the members of our channel and everyone on the
/// server.
pub(crate) fn refresh_tree(&self) {
let Some(view) = self.view() else {
vm::list::sync(&self.models.tree, &[]);
vm::list::sync(&self.models.members, &[]);
vm::list::sync(&self.models.server_members, &[]);
return;
};
let input = vm::tree::TreeInput {
@@ -275,12 +281,39 @@ impl App {
groups: &view.server_groups,
};
vm::list::sync(&self.models.tree, &vm::tree::rows(&input));
let members = if view.state.voice == VoiceState::Connected {
vm::tree::members(&input)
} else {
Vec::new()
};
let connected = view.state.voice == VoiceState::Connected;
let members = if connected { vm::tree::members(&input) } else { Vec::new() };
vm::list::sync(&self.models.members, &members);
// The people in our channel first while their view is shown.
let watching = self.watch.as_ref().is_some_and(|w| w.shown);
let voice_first = connected && (self.voice_view || watching);
let everyone = vm::tree::server_members(&input, voice_first);
let filter = self.member_filter.trim().to_lowercase();
let shown =
if filter.is_empty() { everyone } else { vm::tree::matching(everyone, &filter) };
vm::list::sync(&self.models.server_members, &shown);
if let Some(ui) = self.ui.upgrade() {
let total = view.presence.clients.values().filter(|c| !c.is_query).count();
ui.global::<crate::app::Bridge>().set_member_total(total as i32);
}
}
/// The members panel's search.
pub(crate) fn search_members(&mut self, text: String) {
if self.member_filter != text {
self.member_filter = text;
self.refresh_tree();
}
}
/// The voice channel view was opened or closed: its chat is our
/// channel's, and its people lead the members panel.
pub(crate) fn show_voice_view(&mut self, on: bool) {
self.voice_view = on;
if on && let Some(channel) = self.view().and_then(|v| v.state.own_channel) {
self.open_chat(voelin_model::ChatTarget::Channel(channel), true);
}
self.refresh_tree();
}
pub(crate) fn toggle_collapse(&mut self, channel: u64) {
+42 -2
View File
@@ -7,7 +7,7 @@ use tracing::warn;
use voelin_core::media::audio_source_specs;
use voelin_core::settings::{STREAM_AUDIO_SOURCES, STREAM_BITRATE_KBPS, STREAM_FPS};
use voelin_core::stream::{
EndReason, LayerId, LayerSpec, LeaveReason, StreamSetup, ViewerInfo, ViewerState,
EndReason, LayerId, LayerSpec, LeaveReason, StreamKind, StreamSetup, ViewerInfo, ViewerState,
};
use voelin_core::{Command, Event, StreamState, WatchState};
@@ -42,7 +42,7 @@ pub(crate) struct Watch {
ended: bool,
has_frame: bool,
/// Shown instead of the chat.
shown: bool,
pub(crate) shown: bool,
decoder: Option<Decoder>,
/// When the picture started, for the elapsed time.
since: Option<std::time::Instant>,
@@ -105,6 +105,16 @@ fn share_end_text(reason: &EndReason) -> String {
}
}
/// "8 Mbit/s", "640 kbit/s" (the stream's announced bitrate, kbit/s); "" for 0.
fn bitrate_text(kbps: u32) -> String {
match kbps {
0 => String::new(),
1..=999 => format!("{kbps} kbit/s"),
_ if kbps.is_multiple_of(1000) => format!("{} Mbit/s", kbps / 1000),
_ => format!("{:.1} Mbit/s", f64::from(kbps) / 1000.0),
}
}
impl App {
pub(crate) fn stream_event(&mut self, event: Event) {
match event {
@@ -216,9 +226,18 @@ impl App {
id: s.id.clone().into(),
name: s.name.clone().into(),
streamer: view.nickname(s.streamer.0).into(),
streamer_id: i32::from(s.streamer.0),
audio: s.audio,
watching,
own: view.state.own_client == Some(s.streamer.0),
kind: match s.kind {
StreamKind::Screen => "Screen",
StreamKind::Window => "Window",
StreamKind::Camera => "Camera",
StreamKind::Other(_) => "",
}
.into(),
bitrate: bitrate_text(s.bitrate).into(),
});
}
// Streams that started before we joined: the server did not
@@ -235,6 +254,7 @@ impl App {
items.push(StreamItem {
name: c.nickname.clone().into(),
streamer: c.nickname.clone().into(),
streamer_id: i32::from(c.id),
..StreamItem::default()
});
}
@@ -248,6 +268,7 @@ impl App {
audio: false,
watching: self.watch.as_ref().is_some_and(|w| w.session.is_none() && !w.ended),
own: false,
..StreamItem::default()
});
}
bridge.set_streams_available(self.demo || view.is_some_and(|v| v.streams_available()));
@@ -601,6 +622,8 @@ impl App {
});
self.refresh_viewer();
self.refresh_streams();
// The people in our channel lead the members panel beside the viewer.
self.refresh_tree();
}
/// `VOELIN_OPEN=watch`: watch the first stream of our channel.
@@ -651,6 +674,8 @@ impl App {
});
self.refresh_viewer();
self.refresh_streams();
// The people in our channel lead the members panel beside the viewer.
self.refresh_tree();
}
/// A decoded picture is waiting.
@@ -681,6 +706,8 @@ impl App {
}
self.refresh_viewer();
self.refresh_streams();
// The people in our channel lead the members panel beside the viewer.
self.refresh_tree();
}
/// Stop watching and close the viewer.
@@ -695,6 +722,8 @@ impl App {
self.set_fullscreen(false);
self.refresh_viewer();
self.refresh_streams();
// The people in our channel lead the members panel beside the viewer.
self.refresh_tree();
}
pub(crate) fn set_stream_volume(&mut self, percent: f32) {
@@ -726,3 +755,14 @@ impl App {
ui.window().set_fullscreen(full);
}
}
#[cfg(test)]
mod tests {
#[test]
fn bitrates() {
assert_eq!(super::bitrate_text(0), "");
assert_eq!(super::bitrate_text(640), "640 kbit/s");
assert_eq!(super::bitrate_text(8000), "8 Mbit/s");
assert_eq!(super::bitrate_text(4608), "4.6 Mbit/s");
}
}
+29 -2
View File
@@ -49,12 +49,29 @@ pub struct LineCtx {
pub downloads: Vec<(usize, FileItem)>,
}
fn time_of(ts_ms: i64) -> String {
/// When a message was sent, for its header (see [`stamp`]).
pub fn time_of(ts_ms: i64) -> String {
chrono::DateTime::from_timestamp_millis(ts_ms)
.map(|t| t.with_timezone(&chrono::Local).format("%H:%M").to_string())
.map(|t| {
stamp(t.with_timezone(&chrono::Local).naive_local(), chrono::Local::now().naive_local())
})
.unwrap_or_default()
}
/// "Today at 10:14", "Yesterday at 10:14", "12 Mar at 10:14", and the year
/// when it is not this one.
pub fn stamp(then: chrono::NaiveDateTime, now: chrono::NaiveDateTime) -> String {
use chrono::Datelike;
let time = then.format("%H:%M");
let days = (now.date() - then.date()).num_days();
match days {
0 => format!("Today at {time}"),
1 => format!("Yesterday at {time}"),
_ if then.year() == now.year() => format!("{} at {time}", then.format("%-d %b")),
_ => format!("{} at {time}", then.format("%-d %b %Y")),
}
}
/// "2.4 MB", "912 kB", "48 B".
pub fn size_text(bytes: u64) -> String {
const UNITS: [(u64, &str); 3] = [(1 << 30, "GB"), (1 << 20, "MB"), (1 << 10, "kB")];
@@ -272,6 +289,16 @@ mod tests {
assert!(line.text.starts_with("here you go"));
}
#[test]
fn stamps() {
let at = |d: &str| chrono::NaiveDateTime::parse_from_str(d, "%Y-%m-%d %H:%M").unwrap();
let now = at("2026-10-03 09:00");
assert_eq!(stamp(at("2026-10-03 08:05"), now), "Today at 08:05");
assert_eq!(stamp(at("2026-10-02 23:59"), now), "Yesterday at 23:59");
assert_eq!(stamp(at("2026-03-12 10:14"), now), "12 Mar at 10:14");
assert_eq!(stamp(at("2025-12-31 10:14"), now), "31 Dec 2025 at 10:14");
}
#[test]
fn sizes() {
assert_eq!(size_text(48), "48 B");
+213 -44
View File
@@ -1,4 +1,5 @@
//! The channel tree and the members of our channel.
//! The channel tree, the members of our channel and everyone on the
//! server for the members panel.
use std::collections::{HashMap, HashSet};
use std::path::PathBuf;
@@ -147,58 +148,166 @@ pub fn stats(p: &Presence) -> String {
/// admins). TeamSpeak has no flag for it, so the usual names are matched.
fn is_admin_group(name: &str) -> bool {
let lower = name.to_lowercase();
["admin", "owner", "operator", "moderator", "leiter"].iter().any(|w| lower.contains(w))
["admin", "owner", "operator", "leiter"].iter().any(|w| lower.contains(w))
}
/// Moderator groups, shown as a role next to the name.
fn is_moderator_group(name: &str) -> bool {
name.to_lowercase().contains("mod")
}
impl TreeInput<'_> {
/// The position of a client's group in display order (no group last).
fn group_rank(&self, client: &ClientInfo) -> usize {
self.groups.iter().position(|g| client.server_groups.contains(&g.id)).unwrap_or(usize::MAX)
}
/// One row of the members panel or the voice channel, under `section`.
fn member(&self, c: &ClientInfo, section: &Section) -> MemberItem {
let talking = talking(self, c);
let group = self.group_of(c).map_or("", |g| g.name.as_str());
let admin = is_admin_group(group);
// Someone elsewhere on the server: where they are says more than
// "Listening".
let elsewhere = self.own_channel != Some(c.channel)
&& !talking
&& c.streaming != Some(true)
&& c.away.is_none();
let status = match self.presence.channels.get(&c.channel) {
Some(channel) if elsewhere => format!("In {}", channel.name),
_ => status_of(c, talking),
};
MemberItem {
id: c.id as i32,
name: c.nickname.clone().into(),
initials: avatar::initials(&c.nickname).into(),
tint: avatar::tint(&c.nickname),
avatar: self.avatar(c),
talking,
muted: c.input_muted,
sound_off: c.output_muted,
away: c.away.is_some(),
streaming: c.streaming == Some(true),
myself: self.own_client == Some(c.id),
status: status.into(),
away_message: c.away.clone().unwrap_or_default().into(),
group: section.title.clone().into(),
group_icon: section.icon.clone(),
first_in_group: false,
group_count: 0,
admin,
role: if !admin && is_moderator_group(group) { group.into() } else { "".into() },
priority: c.priority_speaker,
commander: c.channel_commander,
recording: c.recording,
talk_power: c.talk_power,
}
}
}
/// A heading of the members panel.
#[derive(Clone, Default)]
struct Section {
title: String,
icon: slint::Image,
}
/// Rows in sections: each section's first row carries the heading and how
/// many rows follow.
fn sectioned(
input: &TreeInput,
mut clients: Vec<(Section, usize, &ClientInfo)>,
) -> Vec<MemberItem> {
clients.sort_by_key(|(_, rank, c)| (*rank, c.nickname.to_lowercase(), c.id));
let mut rows: Vec<MemberItem> = clients.iter().map(|(s, _, c)| input.member(c, s)).collect();
let mut start = 0;
while start < rows.len() {
let rank = clients[start].1;
let count = clients[start..].iter().take_while(|(_, r, _)| *r == rank).count();
rows[start].first_in_group = true;
rows[start].group_count = count as i32;
start += count;
}
rows
}
/// The section of a client's server group.
fn group_section(input: &TreeInput, client: &ClientInfo) -> (Section, usize) {
match input.group_of(client) {
Some(g) => (
Section {
title: g.name.clone(),
icon: avatar::image(
Some(g.icon).filter(|i| *i != 0).and_then(|i| input.icons.get(&i)),
),
},
1 + input.group_rank(client),
),
None => (Section { title: "Online".into(), ..Default::default() }, usize::MAX),
}
}
/// The clients in our channel, grouped by server group (in the server's
/// display order) and by name inside a group.
pub fn members(input: &TreeInput) -> Vec<MemberItem> {
let Some(channel) = input.own_channel else { return Vec::new() };
let mut clients: Vec<&ClientInfo> = input.presence.members(channel).collect();
clients.sort_by_key(|c| {
let group = input.group_of(c);
(
group.map_or(i32::MAX, |g| g.sort_id),
group.map_or(String::new(), |g| g.name.clone()),
c.nickname.to_lowercase(),
)
});
let mut previous: Option<String> = None;
clients
.into_iter()
let clients = input
.presence
.members(channel)
.map(|c| {
let talking = talking(input, c);
let group = input.group_of(c);
let name = group.map(|g| g.name.clone()).unwrap_or_default();
let first = previous.as_deref() != Some(name.as_str());
previous = Some(name.clone());
MemberItem {
id: c.id as i32,
name: c.nickname.clone().into(),
initials: avatar::initials(&c.nickname).into(),
tint: avatar::tint(&c.nickname),
avatar: input.avatar(c),
talking,
muted: c.input_muted,
sound_off: c.output_muted,
away: c.away.is_some(),
streaming: c.streaming == Some(true),
myself: input.own_client == Some(c.id),
status: status_of(c, talking).into(),
away_message: c.away.clone().unwrap_or_default().into(),
group: name.into(),
group_icon: avatar::image(
group.map(|g| g.icon).filter(|i| *i != 0).and_then(|i| input.icons.get(&i)),
),
first_in_group: first,
admin: group.is_some_and(|g| is_admin_group(&g.name)),
priority: c.priority_speaker,
commander: c.channel_commander,
recording: c.recording,
talk_power: c.talk_power,
let (section, rank) = group_section(input, c);
(section, rank, c)
})
.collect();
sectioned(input, clients)
}
/// The rows whose name contains `filter` (lower case), in sections
/// counted again.
pub fn matching(rows: Vec<MemberItem>, filter: &str) -> Vec<MemberItem> {
let mut rows: Vec<MemberItem> =
rows.into_iter().filter(|m| m.name.to_lowercase().contains(filter)).collect();
let mut start = 0;
while start < rows.len() {
let group = rows[start].group.clone();
let count = rows[start..].iter().take_while(|m| m.group == group).count();
for (i, row) in rows[start..start + count].iter_mut().enumerate() {
row.first_in_group = i == 0;
row.group_count = if i == 0 { count as i32 } else { 0 };
}
start += count;
}
rows
}
/// Everyone on the server for the members panel: first the people in our
/// voice channel (`voice_first`, in the voice channel and stream views) or
/// those streaming, then each server group in the server's order.
pub fn server_members(input: &TreeInput, voice_first: bool) -> Vec<MemberItem> {
let first = Section {
title: if voice_first { "In Voice" } else { "Streaming" }.into(),
icon: slint::Image::default(),
};
let clients = input
.presence
.clients
.values()
.filter(|c| !c.is_query)
.map(|c| {
let lead = if voice_first {
input.own_channel == Some(c.channel)
} else {
c.streaming == Some(true)
};
if lead {
(first.clone(), 0, c)
} else {
let (section, rank) = group_section(input, c);
(section, rank, c)
}
})
.collect()
.collect();
sectioned(input, clients)
}
#[cfg(test)]
@@ -328,4 +437,64 @@ mod tests {
assert_eq!(rows, [("Carol", "Server Admin", true), ("bob", "Guest", true)]);
assert!(members[0].admin && !members[1].admin);
}
#[test]
fn everyone_in_sections() {
let mut p = presence();
p.clients.get_mut(&10).unwrap().server_groups = vec![7];
p.clients.get_mut(&12).unwrap().server_groups = vec![7];
p.clients.get_mut(&12).unwrap().streaming = Some(true);
p.clients.get_mut(&11).unwrap().server_groups = vec![6];
let group = |id, sort_id, name: &str| GroupInfo {
id,
name: name.into(),
icon: 0,
sort_id,
..Default::default()
};
let e = Extras {
groups: vec![group(6, 10, "Moderator"), group(7, 20, "Guest")],
..Default::default()
};
let (t, c, pb) = (HashSet::new(), HashSet::new(), ClientPlaybackMap::new());
let rows = |voice_first| {
server_members(&input(&p, &t, &c, &pb, "", &e), voice_first)
.iter()
.map(|m| {
(
m.name.to_string(),
m.first_in_group.then(|| format!("{} — {}", m.group, m.group_count)),
m.status.to_string(),
)
})
.collect::<Vec<_>>()
};
let row = |name: &str, head: Option<&str>, status: &str| {
(name.to_owned(), head.map(str::to_owned), status.to_owned())
};
// The query client is left out; people elsewhere show their channel.
assert_eq!(
rows(false),
[
row("Carol", Some("Streaming — 1"), "Streaming"),
row("bob", Some("Moderator — 1"), "Listening"),
row("Alice", Some("Guest — 1"), "In Lobby"),
]
);
assert_eq!(
rows(true),
[
row("bob", Some("In Voice — 1"), "Listening"),
row("Alice", Some("Guest — 2"), "In Lobby"),
row("Carol", None, "Streaming"),
]
);
let all = server_members(&input(&p, &t, &c, &pb, "", &e), false);
assert_eq!(all[1].role, "Moderator");
assert!(!all[1].admin);
// The search keeps the sections of what it finds.
let found = matching(all, "al");
assert_eq!(found.len(), 1);
assert!(found[0].first_in_group && found[0].group == "Guest" && found[0].group_count == 1);
}
}