voelin-ui: the phone's voice channel screen, and Home as the mockups show
The phone had no voice channel view: the people, the streams and the channel's chat were spread over three tabs, and watching replaced the Chat tab with a bare player. The voice channel now has a screen of its own (design mockup 02): the channel's name and topic with Leave, the stream we watch with LIVE, viewers, quality, volume and full screen (or a card to watch one), the people with talking and muted marks, crowns and LIVE, an Invite button that copies a ts3server:// link to the channel, the channel chat with its pins, topics and members, the composer with hold-to-talk when push-to-talk is the transmit mode, and Mute, Deafen, Go Live, Share and Leave in place of the navigation. It opens from the top bar's voice button, the voice card, the Activity tab and by watching a stream; back keeps a stream playing behind it. The navigation: Home's server cards and Open went nowhere on the phone (the Home tab stayed); a server now switches to the Servers tab. The Chat tab is Chats and stays the chat while watching. The studio, like the voice screen, goes without the bottom bar, as its mockup does. The pins, topics and server members (beside the chat on the desktop) open as pages over the phone's screen. Home gains what mockup 01 has and the engine knows: who is online on the current server, its chats with their last message and time (emoji left out of the one-line preview), the servers (side by side on the phone) and the streams of our channel. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6cfec67eee
commit
5f51eb15a2
16 files changed
+1348
-35
No files matched your search
@@ -61,4 +61,5 @@ pub(super) fn wire(ui: &MainWindow) {
|
||||
bridge.on_client_audio_changed(|form| {
|
||||
with_app(|app| app.client_playback_changed(&form));
|
||||
});
|
||||
bridge.on_invite(|| with_app(|app| app.invite_link()).unwrap_or_default().into());
|
||||
}
|
||||
@@ -335,7 +335,17 @@ impl App {
|
||||
let tabs: Vec<ChatTab> = view
|
||||
.tabs
|
||||
.iter()
|
||||
.map(|t| ChatTab {
|
||||
.map(|t| {
|
||||
let (last, time) = t
|
||||
.messages
|
||||
.last()
|
||||
.map(|m| vm::chat::preview(&m.message.message))
|
||||
.unwrap_or_default();
|
||||
(t, last, time)
|
||||
})
|
||||
.map(|(t, last, time)| ChatTab {
|
||||
last: last.into(),
|
||||
time: time.into(),
|
||||
title: t.title.clone().into(),
|
||||
name: t.title.trim_start_matches(['#', '@']).into(),
|
||||
kind: match t.target {
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
//! appearance, or 0-4), `about`, `share`, `bookmark` (add a server),
|
||||
//! `emoji` (the picker), `client` (the volume dialog of the first other
|
||||
//! client once connected), `panel` / `no-panel` (the members panel),
|
||||
//! `voice` (the voice channel view), `pins`, `topics` (the drawers),
|
||||
//! `voice` (the voice channel view; on the phone its own screen),
|
||||
//! `members` (the phone's members page), `pins`, `topics` (the drawers),
|
||||
//! `topic:<id>` (a topic's messages), `member` (the member card of the
|
||||
//! first other client), `watch` (the first stream; with sample data the
|
||||
//! local test pattern in its place), `popout` (the same, popped out),
|
||||
@@ -157,6 +158,8 @@ pub(crate) fn start(ui: &MainWindow, switches: &Switches) -> Running {
|
||||
"tab" => nav.set_mobile_tab(mobile_tab(arg)),
|
||||
"voice" => nav.invoke_show_voice(true),
|
||||
"pins" => nav.invoke_show_pins(true),
|
||||
// The phone's members page.
|
||||
"members" => nav.set_members_open(true),
|
||||
"topics" => nav.invoke_show_topics(true),
|
||||
"topic" => {
|
||||
with_app(|app| {
|
||||
|
||||
@@ -316,6 +316,33 @@ impl App {
|
||||
self.refresh_tree();
|
||||
}
|
||||
|
||||
/// A link to the voice channel we are in, for the Invite button (which
|
||||
/// copies it); empty, with a note, without one.
|
||||
pub(crate) fn invite_link(&mut self) -> String {
|
||||
let bookmark = self.current.and_then(|id| self.bookmark(id)).map(|b| b.address.clone());
|
||||
let path = self.view().and_then(|v| {
|
||||
let mut names = Vec::new();
|
||||
let mut channel = v.presence.channels.get(&v.state.own_channel?)?;
|
||||
loop {
|
||||
names.push(channel.name.clone());
|
||||
match v.presence.channels.get(&channel.parent) {
|
||||
Some(parent) if channel.parent != 0 && names.len() < 64 => channel = parent,
|
||||
_ => break,
|
||||
}
|
||||
}
|
||||
names.reverse();
|
||||
Some(names)
|
||||
});
|
||||
let (Some(address), Some(path)) = (bookmark, path) else {
|
||||
self.set_status("Join a voice channel to invite others to it");
|
||||
return String::new();
|
||||
};
|
||||
let path: Vec<&str> = path.iter().map(String::as_str).collect();
|
||||
let link = vm::servers::invite_link(&address, &path);
|
||||
self.set_status(format!("Copied an invite to {}: {link}", path.last().unwrap_or(&"")));
|
||||
link
|
||||
}
|
||||
|
||||
pub(crate) fn toggle_collapse(&mut self, channel: u64) {
|
||||
if let Some(view) = self.view_mut()
|
||||
&& !view.collapsed.remove(&channel)
|
||||
|
||||
@@ -346,6 +346,12 @@ impl App {
|
||||
.and_then(|v| v.streams.iter().find(|s| s.id == watch.stream_id))
|
||||
.map_or(-1, |s| i32::from(s.streamer.0));
|
||||
bridge.set_viewer_streamer_id(streamer);
|
||||
let members = &self.models.members;
|
||||
bridge.set_viewer_streamer_admin(
|
||||
(0..members.row_count())
|
||||
.filter_map(|i| members.row_data(i))
|
||||
.any(|m| m.id == streamer && m.admin),
|
||||
);
|
||||
bridge.set_viewer_elapsed(watch.elapsed().into());
|
||||
let viewers = self.view().and_then(|v| v.stream_viewers.get(&watch.stream_id)).copied();
|
||||
bridge.set_viewer_count(viewers.unwrap_or(0) as i32);
|
||||
|
||||
@@ -99,6 +99,29 @@ fn without_links(text: &str, files: &[FileRef]) -> String {
|
||||
out.replace("[/URL]", "").replace("[/url]", "").trim().to_owned()
|
||||
}
|
||||
|
||||
/// A chat's last message for a list of chats, on one line ("Mira: the
|
||||
/// banner I promised: guild-banner.png"), and when it came.
|
||||
pub fn preview(message: &ChatMessage) -> (String, String) {
|
||||
let text = if message.blocked {
|
||||
"Message from a blocked contact.".to_owned()
|
||||
} else {
|
||||
let files = message.file_refs();
|
||||
let names = files.iter().map(|f| f.name.as_str());
|
||||
let text = without_links(&message.text, &files);
|
||||
std::iter::once(text.as_str()).chain(names).collect::<Vec<_>>().join(" ")
|
||||
};
|
||||
// A one-line text cannot show emoji (they are pictures): left out.
|
||||
let plain = match emoji::runs(&text) {
|
||||
Some(runs) => runs.into_iter().filter(|r| r.emoji.is_none()).map(|r| r.text).collect(),
|
||||
None => text,
|
||||
};
|
||||
let mut text = plain.split_whitespace().collect::<Vec<_>>().join(" ");
|
||||
if text.is_empty() {
|
||||
text = "sent an emoji".into();
|
||||
}
|
||||
(format!("{}: {text}", message.author_name), time_of(message.ts_ms))
|
||||
}
|
||||
|
||||
fn runs_model(runs: &[emoji::Run]) -> ModelRc<TextRun> {
|
||||
ModelRc::from(Rc::new(VecModel::from(
|
||||
runs.iter()
|
||||
@@ -289,6 +312,23 @@ mod tests {
|
||||
assert!(line.text.starts_with("here you go"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn previews_are_one_line() {
|
||||
let url = "ts3file://plan.pdf?channel=2&path=/&filename=plan.pdf&isDir=0&size=2048";
|
||||
let text = format!("route\nfor tonight: [URL={url}]plan.pdf[/URL]");
|
||||
let (last, time) = preview(&message("Mira", &text, 0));
|
||||
assert_eq!(last, "Mira: route for tonight: plan.pdf");
|
||||
assert!(!time.is_empty());
|
||||
assert_eq!(
|
||||
preview(&message("Ari", "co-op later? 👀 Posting", 0)).0,
|
||||
"Ari: co-op later? Posting"
|
||||
);
|
||||
assert_eq!(preview(&message("dex", "🎉🎉", 0)).0, "dex: sent an emoji");
|
||||
let mut blocked = message("X", "secret", 0);
|
||||
blocked.blocked = true;
|
||||
assert_eq!(preview(&blocked).0, "X: Message from a blocked contact.");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stamps() {
|
||||
let at = |d: &str| chrono::NaiveDateTime::parse_from_str(d, "%Y-%m-%d %H:%M").unwrap();
|
||||
|
||||
@@ -31,10 +31,69 @@ pub fn item(bookmark: &Bookmark, state: &SessionState, unread: i32, live: bool)
|
||||
}
|
||||
}
|
||||
|
||||
/// A `ts3server://` link that joins the channel at `path` (its names from
|
||||
/// the top) on the server at `address` (`host`, `host:port` or
|
||||
/// `[v6]:port`), as TeamSpeak clients open them.
|
||||
pub fn invite_link(address: &str, path: &[&str]) -> String {
|
||||
fn encode(text: &str) -> String {
|
||||
text.bytes()
|
||||
.map(|b| match b {
|
||||
b'A'..=b'Z' | b'a'..=b'z' | b'0'..=b'9' | b'-' | b'.' | b'_' | b'~' => {
|
||||
char::from(b).to_string()
|
||||
}
|
||||
_ => format!("%{b:02X}"),
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
let address = address.trim();
|
||||
// A port follows the last colon, unless that colon is inside an IPv6
|
||||
// address without brackets.
|
||||
let (host, port) = match address.rsplit_once(':') {
|
||||
Some((host, port))
|
||||
if !port.is_empty()
|
||||
&& port.bytes().all(|b| b.is_ascii_digit())
|
||||
&& (!host.contains(':') || host.ends_with(']')) =>
|
||||
{
|
||||
(host, Some(port))
|
||||
}
|
||||
_ => (address, None),
|
||||
};
|
||||
let mut link = format!("ts3server://{host}");
|
||||
let mut query = Vec::new();
|
||||
if let Some(port) = port {
|
||||
query.push(format!("port={port}"));
|
||||
}
|
||||
if !path.is_empty() {
|
||||
let names: Vec<String> = path.iter().map(|n| encode(n)).collect();
|
||||
query.push(format!("channel={}", names.join("/")));
|
||||
}
|
||||
if !query.is_empty() {
|
||||
link.push('?');
|
||||
link.push_str(&query.join("&"));
|
||||
}
|
||||
link
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn invite_links() {
|
||||
assert_eq!(
|
||||
invite_link("ts.example.com:9988", &["Gaming", "Raid Night"]),
|
||||
"ts3server://ts.example.com?port=9988&channel=Gaming/Raid%20Night"
|
||||
);
|
||||
assert_eq!(invite_link(" ts.example.com ", &[]), "ts3server://ts.example.com");
|
||||
assert_eq!(
|
||||
invite_link("[2001:db8::1]:9987", &["Chill & Co"]),
|
||||
"ts3server://[2001:db8::1]?port=9987&channel=Chill%20%26%20Co"
|
||||
);
|
||||
// A bare IPv6 address has no port.
|
||||
assert_eq!(invite_link("2001:db8::1", &[]), "ts3server://2001:db8::1");
|
||||
assert_eq!(invite_link("h:x", &["Ä/b"]), "ts3server://h:x?channel=%C3%84%2Fb");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn states() {
|
||||
let mut s = SessionState::default();
|
||||
|
||||
Reference in new issue
Block a user