diff --git a/CHANGELOG.md b/CHANGELOG.md index eb1b651..815ddbb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -72,14 +72,18 @@ User-visible changes of the apps and the `tsgw` gateway. The format follows - Older chat messages load when scrolling up, above the messages on screen, which stay in place; the Older messages button remains for a chat that fits on the screen. -- One dialog adds a server, with Save and Connect (Enter connects); Home's - Join a Server opens it too. Connect connects only a server it saved (Join - connected the server shown before when saving failed). +- One dialog adds a server, with Save and Connect (Enter connects). + Connect connects only a server it saved (Join connected the server shown + before when saving failed). - A slimmer top bar on desktop: only the search and the bell. The bell's panel opens under the bell and is as tall as its notices; the members button is in the voice channel's header (as in the chat's), About in Settings. The user card has no settings gear (the rail's stays); its avatar and name open your account. +- Home shows where you left off (the last voice channel, joined in one + click) and your unread mentions; the welcome banner shows only before the + first server. Friends show once, the quick actions are gone, and the + sidebar lists your recent private chats. ### Fixed diff --git a/crates/voelin-ui/src/app.rs b/crates/voelin-ui/src/app.rs index 4bdeede..e84af7a 100644 --- a/crates/voelin-ui/src/app.rs +++ b/crates/voelin-ui/src/app.rs @@ -1022,6 +1022,7 @@ impl App { let view = self.sessions.entry(id).or_default(); let was_voice = view.state.voice; let was_observe = view.state.observe; + let was_channel = view.state.own_channel; view.state = state.clone(); if state.voice != VoiceState::Connected { view.focused_own_channel = false; @@ -1060,6 +1061,12 @@ impl App { self.sessions.entry(id).or_default().focused_own_channel = true; } } + // Where we are with voice, when it changed here: home's last + // place, which `refresh_servers` shows (voice on another + // server does not take it back at each of its events). + if (state.voice, state.own_channel) != (was_voice, was_channel) { + self.remember_voice(id); + } self.refresh_servers(); self.refresh_toolbar(); self.refresh_tree(); @@ -1090,9 +1097,19 @@ impl App { // their pictures. let said = crate::chat::server_texts(&view.presence.server) != crate::chat::server_texts(&presence.server); + // Our channel's path: known only now (a new connection), + // or renamed. + let path = |v: &SessionView| { + v.state.own_channel.map(|c| crate::vm::tree::channel_path(&v.presence, c)) + }; + let path_before = path(view); view.presence = presence; + let renamed = path(view) != path_before; self.apply_client_playback(session as i64); self.join_after_connect(session as i64); + if renamed && self.remember_voice(session as i64) { + self.refresh_servers(); + } if self.current == Some(session as i64) { if said { self.fetch_previews(session as i64); diff --git a/crates/voelin-ui/src/bind/social.rs b/crates/voelin-ui/src/bind/social.rs index 343c443..d241e46 100644 --- a/crates/voelin-ui/src/bind/social.rs +++ b/crates/voelin-ui/src/bind/social.rs @@ -26,6 +26,9 @@ pub(super) fn wire(ui: &MainWindow) { bridge.on_connect_server(|id| { with_app(|app| app.connect_server(i64::from(id))); }); + bridge.on_resume(|| { + with_app(|app| app.resume()); + }); // Friends. bridge.on_friends_tab(|tab| { diff --git a/crates/voelin-ui/src/dev.rs b/crates/voelin-ui/src/dev.rs index 8d01b5c..00de768 100644 --- a/crates/voelin-ui/src/dev.rs +++ b/crates/voelin-ui/src/dev.rs @@ -28,6 +28,8 @@ //! `channel-password` (the password dialog of the first locked channel, //! the sample's Officers; `channel-password:wrong` as after a refused //! one), `actions` (the last message's actions, as if hovered), +//! `first-run` (home's banner as before the first server, over the +//! sample data), //! `unread` (the current chat read up to five messages before its end: //! the "New" divider, scrolled up to; `unread:end` ten messages before, //! at the list's end, under the bar that counts the new messages), @@ -77,6 +79,7 @@ use voelin_store::{Bookmark, MessageSource}; use crate::app::{ App, Bridge, MainWindow, MobileTab, Nav, Page, RecordingItem, SettingsSection, with_app, }; +use crate::settings::LastVoice; /// The switches read at start. #[derive(Clone, Debug, Default)] @@ -294,6 +297,8 @@ pub(crate) fn start(ui: &MainWindow, switches: &Switches) -> Running { } // A screenshot cannot hover. "actions" => nav.set_show_actions(true), + // Home as before the first server, over the sample data. + "first-run" => nav.set_first_run(true), // `end`: further back, so the divider is above the view. "unread" => { with_app(|app| open_unread(app, if arg == "end" { 10 } else { 5 })); @@ -523,6 +528,13 @@ fn demo_ui(app: &mut App) { bookmark(DEMO + 1, "Pixel Lounge", "pixel.example"), bookmark(DEMO + 2, "Dev TS3", "127.0.0.1:9987"), ]; + // Home's "Continue where you left off": a channel of a server without + // voice, so it shows Join. + app.settings.last_voice = Some(LastVoice { + bookmark: DEMO + 1, + address: "pixel.example".into(), + channel: vec!["Art Corner".into()], + }); app.current = Some(DEMO); let session = DEMO as u64; @@ -1095,8 +1107,8 @@ fn demo_social(app: &mut App) { }, }); - // Notifications: a mention, a message, an event, a friend online (and - // the poke above). + // Notifications: two mentions (unread: home shows them), a message, an + // event, a friend online (and the poke above). use crate::social::{NoticeKind, NoticeTarget}; app.notify( NoticeKind::Mention, @@ -1106,6 +1118,14 @@ fn demo_social(app: &mut App) { "Talon".into(), Some("demo-6".into()), ); + app.notify( + NoticeKind::Mention, + "Zeph mentioned you".into(), + "Nova, are you healing tonight? — #Raid Night · Nightfall Guild".into(), + NoticeTarget::Chat(DEMO, ChatTarget::Channel(4)), + "Zeph".into(), + Some("demo-7".into()), + ); app.notify( NoticeKind::Event, "Late Night Lofi & Chat starts in 50 min".into(), @@ -1132,7 +1152,7 @@ fn demo_social(app: &mut App) { ); for (i, n) in app.social.notices.iter_mut().enumerate() { n.ts_ms = now - (i as i64 * 9 + 2) * min; - n.unread = i < 3; + n.unread = i < 3 || n.kind == NoticeKind::Mention; } app.refresh_notices(); diff --git a/crates/voelin-ui/src/home.rs b/crates/voelin-ui/src/home.rs index 57ddab4..f6bbe81 100644 --- a/crates/voelin-ui/src/home.rs +++ b/crates/voelin-ui/src/home.rs @@ -1,15 +1,20 @@ -//! The home page (design mockup 01): live streams on our servers, what is -//! happening there (events, scheduled streams, server news), and the -//! Library of recordings and clips. Friends are in `social.rs`, the recent -//! chats in `messages.rs`. +//! The home page (design mockup 01): where we were with voice last, live +//! streams on our servers, what is happening there (events, scheduled +//! streams, server news), and the Library of recordings and clips. +//! Friends and the unread mentions are in `social.rs`, the recent chats in +//! `messages.rs`. use std::path::{Path, PathBuf}; use slint::ComponentHandle; use voelin_core::VoiceState; -use crate::app::{App, Bridge, HappeningItem, LiveItem, Page, RecordingItem}; +use crate::app::{ + App, Bridge, HappeningItem, LiveItem, Page, RecordingItem, ResumeItem, ServerItem, +}; +use crate::settings::LastVoice; use crate::vm; +use crate::vm::home::ResumeAction; use crate::vm::social::{event_when, plain}; /// What a "What's Happening" entry opens. @@ -240,6 +245,62 @@ impl App { self.connect_voice(); } + fn last_resume(&self) -> Option { + let voice = |id| self.sessions.get(&id).map_or(VoiceState::Disconnected, |v| v.state.voice); + vm::home::resume(self.settings.last_voice.as_ref(), &self.bookmarks, voice) + } + + /// Home's "Continue where you left off", its server as the rail shows + /// it (`servers`). + pub(crate) fn last_place(&self, servers: &[ServerItem]) -> ResumeItem { + let Some(resume) = self.last_resume() else { return ResumeItem::default() }; + let Some(server) = servers.iter().find(|s| i64::from(s.id) == resume.bookmark) else { + return ResumeItem::default(); + }; + ResumeItem { + shown: true, + server_id: server.id, + server: server.name.clone(), + initials: server.initials.clone(), + tint: server.tint, + icon: server.icon.clone(), + channel: resume.title().into(), + open: resume.action == ResumeAction::Open, + connecting: server.status == "connecting", + } + } + + /// The last place's button: its server, connected into the channel + /// unless voice is there already. + pub(crate) fn resume(&mut self) { + let Some(resume) = self.last_resume() else { return }; + self.show_server(resume.bookmark); + if resume.action == ResumeAction::Join { + self.connect_voice_to(Some(resume.path.join("/")), None, None); + } + } + + /// Keep where we are with voice in `session` as the last place + /// (`ui.last_voice`); whether it changed. Not for the sample sessions. + pub(crate) fn remember_voice(&mut self, session: i64) -> bool { + if self.demo_ui { + return false; + } + let Some(view) = self.sessions.get(&session) else { return false }; + let (VoiceState::Connected, Some(cid)) = (view.state.voice, view.state.own_channel) else { + return false; + }; + let channel = vm::tree::channel_path(&view.presence, cid); + let Some(b) = self.bookmark(session).filter(|_| !channel.is_empty()) else { return false }; + let last = LastVoice { bookmark: session, address: b.address.clone(), channel }; + if self.settings.last_voice.as_ref() == Some(&last) { + return false; + } + self.settings.last_voice = Some(last); + self.store_settings(); + true + } + /// The folder of recordings and clips. fn recordings_dir(&self) -> PathBuf { voelin_core::studio::recording_dir(&self.prefs) diff --git a/crates/voelin-ui/src/messages.rs b/crates/voelin-ui/src/messages.rs index 52994c8..7c34abc 100644 --- a/crates/voelin-ui/src/messages.rs +++ b/crates/voelin-ui/src/messages.rs @@ -1,7 +1,7 @@ //! Direct messages (design mockup 02) and the recent chats of the home -//! page: every chat the sessions hold and the newest ones in the history -//! store, across servers; the open private chat with who it is with; TS3 -//! and TS6 offline messages (mail the server keeps). +//! page and its sidebar: every chat the sessions hold and the newest ones +//! in the history store, across servers; the open private chat with who it +//! is with; TS3 and TS6 offline messages (mail the server keeps). //! //! A private chat is a chat tab of its session (`ChatTarget::Private` //! stored under the peer's unique id), so opening one selects its server @@ -237,7 +237,8 @@ impl App { } } - /// The DM list, the recent chats of home and the unread counts. + /// The DM list, the recent chats of home, the private chats of its + /// sidebar and the unread counts. fn refresh_conversations(&self) { let Some(ui) = self.ui.upgrade() else { return }; let bridge = ui.global::(); @@ -251,6 +252,15 @@ impl App { .map(|(i, c)| self.conversation_item(i, c)) .collect(); vm::list::sync(&self.models.social.recent, &recent); + // Shown beside other pages: none is the open one. + let sidebar: Vec = vm::social::sidebar_dms(&dm.chats, 5) + .into_iter() + .map(|i| ConversationItem { + selected: false, + ..self.conversation_item(i, &dm.chats[i]) + }) + .collect(); + vm::list::sync(&self.models.social.sidebar_dms, &sidebar); let private = |c: &&ChatRef| matches!(c.target, ChatTarget::Private(_)); let items: Vec = if dm.tab == 2 { dm.inbox diff --git a/crates/voelin-ui/src/servers.rs b/crates/voelin-ui/src/servers.rs index 11fc3a8..f87d445 100644 --- a/crates/voelin-ui/src/servers.rs +++ b/crates/voelin-ui/src/servers.rs @@ -397,6 +397,7 @@ impl App { }) .collect(); vm::list::sync(&self.models.servers, &items); + bridge.set_last_place(self.last_place(&items)); bridge.set_current_server(self.current.map_or(-1, |id| id as i32)); bridge.set_unread_total(self.view().map_or(0, |v| v.unread())); } @@ -531,20 +532,14 @@ impl App { 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 own = v.presence.channels.get(&v.state.own_channel?)?; - let mut channel = own; - 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(); + let cid = v.state.own_channel?; + let own = v.presence.channels.get(&cid)?; // The link names the channels as the server has them; the // toast as the tree shows them. - Some((names, vm::tree::channel_title(own).0.to_owned())) + Some(( + vm::tree::channel_path(&v.presence, cid), + vm::tree::channel_title(own).0.to_owned(), + )) }); let (Some(address), Some((path, title))) = (bookmark, path) else { self.set_status("Join a voice channel to invite others to it"); diff --git a/crates/voelin-ui/src/settings.rs b/crates/voelin-ui/src/settings.rs index 595d8bb..97e423a 100644 --- a/crates/voelin-ui/src/settings.rs +++ b/crates/voelin-ui/src/settings.rs @@ -271,6 +271,9 @@ pub struct UiSettings { /// "Continue without an account" was chosen on the login page: it does /// not show at start any more (signing in clears it). pub skip_account_prompt: bool, + /// The voice channel we were in last (Home's "Continue where you left + /// off"). + pub last_voice: Option, } impl Default for UiSettings { @@ -283,10 +286,21 @@ impl Default for UiSettings { share: ShareDefaults::default(), crash_reports: false, skip_account_prompt: false, + last_voice: None, } } } +/// Where we were with voice last: the bookmark with the address it had +/// then (one that now points elsewhere does not resume), and the channel's +/// path, its names from the top as the server has them. +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +pub struct LastVoice { + pub bookmark: i64, + pub address: String, + pub channel: Vec, +} + /// The last choices in the share dialog. Frame rate and bitrate are the /// settings `stream.fps` and `stream.bitrate_kbps`; the indices of the /// closest choices of the old lists ([`LEGACY_FPS_CHOICES`], @@ -526,6 +540,15 @@ mod tests { assert!(!parsed.crash_reports, "crash reports are opt-in"); assert_eq!(parsed.ptt_key, "Ctrl+Shift+T"); assert_eq!(parsed.share, ShareDefaults::default()); + assert_eq!(parsed.last_voice, None, "older settings have no last channel"); + let last = LastVoice { + bookmark: 3, + address: "ts.example".into(), + channel: vec!["Games".into(), "Chess".into()], + }; + let settings = UiSettings { last_voice: Some(last.clone()), ..UiSettings::default() }; + let json = serde_json::to_string(&settings).unwrap(); + assert_eq!(serde_json::from_str::(&json).unwrap().last_voice, Some(last)); assert_eq!(serde_json::to_value(ThemeChoice::System).unwrap(), "system"); assert_eq!(ThemeChoice::parse("light"), ThemeChoice::Light); assert_eq!(ThemeChoice::parse("??"), ThemeChoice::Dark); diff --git a/crates/voelin-ui/src/social.rs b/crates/voelin-ui/src/social.rs index 2ccbda8..2d44fa4 100644 --- a/crates/voelin-ui/src/social.rs +++ b/crates/voelin-ui/src/social.rs @@ -169,11 +169,13 @@ pub(crate) struct SocialModels { pub blocked: Rc>, pub live: Rc>, pub recent: Rc>, + pub sidebar_dms: Rc>, pub conversations: Rc>, pub dm_lines: Rc>, pub happenings: Rc>, pub recordings: Rc>, pub notices: Rc>, + pub mentions: Rc>, pub search: Rc>, pub events: Rc>, } @@ -187,11 +189,13 @@ impl SocialModels { blocked: Rc::default(), live: Rc::default(), recent: Rc::default(), + sidebar_dms: Rc::default(), conversations: Rc::default(), dm_lines: Rc::default(), happenings: Rc::default(), recordings: Rc::default(), notices: Rc::default(), + mentions: Rc::default(), search: Rc::default(), events: Rc::default(), }; @@ -201,11 +205,13 @@ impl SocialModels { bridge.set_blocked(ModelRc::from(m.blocked.clone())); bridge.set_live_rooms(ModelRc::from(m.live.clone())); bridge.set_recent_chats(ModelRc::from(m.recent.clone())); + bridge.set_sidebar_dms(ModelRc::from(m.sidebar_dms.clone())); bridge.set_conversations(ModelRc::from(m.conversations.clone())); bridge.set_dm_messages(ModelRc::from(m.dm_lines.clone())); bridge.set_happenings(ModelRc::from(m.happenings.clone())); bridge.set_recordings(ModelRc::from(m.recordings.clone())); bridge.set_notifications(ModelRc::from(m.notices.clone())); + bridge.set_home_mentions(ModelRc::from(m.mentions.clone())); bridge.set_search_results(ModelRc::from(m.search.clone())); bridge.set_events(ModelRc::from(m.events.clone())); m @@ -630,26 +636,31 @@ impl App { self.refresh_notices(); } + /// The bell's notices, and home's unread mentions (the newest three). pub(crate) fn refresh_notices(&self) { let Some(ui) = self.ui.upgrade() else { return }; - let items: Vec = self - .social - .notices - .iter() - .map(|n| NoticeItem { - key: n.key, - kind: n.kind.name().into(), - title: n.title.clone().into(), - body: n.body.clone().into(), - time: ago(n.ts_ms).into(), - unread: n.unread, - initials: vm::avatar::initials(&n.name).into(), - tint: vm::avatar::tint(&n.name), - avatar: n.uid.as_deref().map(|u| self.avatar_of(u)).unwrap_or_default(), - }) - .collect(); + let item = |n: &Notice| NoticeItem { + key: n.key, + kind: n.kind.name().into(), + title: n.title.clone().into(), + body: n.body.clone().into(), + time: ago(n.ts_ms).into(), + unread: n.unread, + initials: vm::avatar::initials(&n.name).into(), + tint: vm::avatar::tint(&n.name), + avatar: n.uid.as_deref().map(|u| self.avatar_of(u)).unwrap_or_default(), + }; + let notices = &self.social.notices; + let items: Vec = notices.iter().map(item).collect(); vm::list::sync(&self.models.social.notices, &items); - let unread = self.social.notices.iter().filter(|n| n.unread).count(); + let mentions: Vec = notices + .iter() + .filter(|n| n.unread && n.kind == NoticeKind::Mention) + .take(3) + .map(item) + .collect(); + vm::list::sync(&self.models.social.mentions, &mentions); + let unread = notices.iter().filter(|n| n.unread).count(); ui.global::().set_notifications_unread(unread as i32); } diff --git a/crates/voelin-ui/src/vm/home.rs b/crates/voelin-ui/src/vm/home.rs new file mode 100644 index 0000000..c0f2b3f --- /dev/null +++ b/crates/voelin-ui/src/vm/home.rs @@ -0,0 +1,114 @@ +//! Home's "Continue where you left off": the voice channel we were in last, +//! if it can still be reached. + +use voelin_core::VoiceState; +use voelin_store::Bookmark; + +use crate::settings::LastVoice; + +/// What the card's button does. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum ResumeAction { + /// Voice is connected there: show the server. + Open, + /// Connect into the channel. + Join, +} + +/// The card: the server, the channel and the button. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct Resume { + pub bookmark: i64, + /// The channel's path, its names from the top as the server has them. + pub path: Vec, + pub action: ResumeAction, +} + +impl Resume { + /// The channel's name as the tree shows it (a spacer's text). + pub fn title(&self) -> &str { + match self.path.as_slice() { + [top] => voelin_model::parse_spacer(top).map_or(top.as_str(), |(_, text)| text), + [.., last] => last, + [] => "", + } + } +} + +/// Where to continue: the last voice channel, unless its bookmark is gone +/// or points at another address now. Open while `voice` says a bookmark is +/// connected, else Join. +pub fn resume( + last: Option<&LastVoice>, + bookmarks: &[Bookmark], + voice: impl Fn(i64) -> VoiceState, +) -> Option { + let last = last.filter(|l| !l.channel.is_empty())?; + bookmarks.iter().find(|b| b.id == last.bookmark && b.address == last.address)?; + let action = match voice(last.bookmark) { + VoiceState::Connected => ResumeAction::Open, + _ => ResumeAction::Join, + }; + Some(Resume { bookmark: last.bookmark, path: last.channel.clone(), action }) +} + +#[cfg(test)] +mod tests { + use super::*; + + fn bookmark(id: i64, address: &str) -> Bookmark { + Bookmark { id, address: address.into(), ..Default::default() } + } + + fn last(bookmark: i64, address: &str, channel: &[&str]) -> LastVoice { + LastVoice { + bookmark, + address: address.into(), + channel: channel.iter().map(|n| n.to_string()).collect(), + } + } + + #[test] + fn resume_cases() { + let bookmarks = [bookmark(1, "ts.example"), bookmark(2, "pixel.example:9988")]; + let offline = |_| VoiceState::Disconnected; + assert_eq!(resume(None, &bookmarks, offline), None, "nothing stored"); + assert_eq!( + resume(Some(&last(3, "gone.example", &["Lobby"])), &bookmarks, offline), + None, + "the bookmark was deleted" + ); + assert_eq!( + resume(Some(&last(1, "old.example", &["Lobby"])), &bookmarks, offline), + None, + "the bookmark has another address now" + ); + assert_eq!(resume(Some(&last(1, "ts.example", &[])), &bookmarks, offline), None); + + let place = last(2, "pixel.example:9988", &["Games", "Chess"]); + let joined = resume(Some(&place), &bookmarks, offline).unwrap(); + assert_eq!(joined.bookmark, 2); + assert_eq!(joined.path, ["Games", "Chess"]); + assert_eq!(joined.action, ResumeAction::Join); + assert_eq!(joined.title(), "Chess"); + let connecting = resume(Some(&place), &bookmarks, |_| VoiceState::Connecting); + assert_eq!(connecting.unwrap().action, ResumeAction::Join); + // Connected elsewhere is not connected there. + let connected = |id| if id == 2 { VoiceState::Connected } else { VoiceState::Disconnected }; + assert_eq!(resume(Some(&place), &bookmarks, connected).unwrap().action, ResumeAction::Open); + let elsewhere = |id| if id == 1 { VoiceState::Connected } else { VoiceState::Disconnected }; + assert_eq!(resume(Some(&place), &bookmarks, elsewhere).unwrap().action, ResumeAction::Join); + } + + #[test] + fn resume_titles() { + let title = |path: &[&str]| { + let path = path.iter().map(|n| n.to_string()).collect(); + Resume { bookmark: 1, path, action: ResumeAction::Join }.title().to_owned() + }; + assert_eq!(title(&["Lobby"]), "Lobby"); + assert_eq!(title(&["[cspacer0]Gaming"]), "Gaming", "a spacer by its text"); + // Only channels at the top are spacers. + assert_eq!(title(&["Games", "[cspacer]Chess"]), "[cspacer]Chess"); + } +} diff --git a/crates/voelin-ui/src/vm/mod.rs b/crates/voelin-ui/src/vm/mod.rs index 8746c99..661237e 100644 --- a/crates/voelin-ui/src/vm/mod.rs +++ b/crates/voelin-ui/src/vm/mod.rs @@ -6,6 +6,7 @@ pub mod avatar; pub mod bbcode; pub mod chat; +pub mod home; pub mod list; pub mod servers; pub mod social; diff --git a/crates/voelin-ui/src/vm/social.rs b/crates/voelin-ui/src/vm/social.rs index 7f84a7a..9bb6f91 100644 --- a/crates/voelin-ui/src/vm/social.rs +++ b/crates/voelin-ui/src/vm/social.rs @@ -1,7 +1,7 @@ //! Texts of the home, friends, messages, bell and events screens: times //! ("12m ago", "Yesterday"), message previews without BBCode (read by -//! `vm::bbcode`), mentions, event dates, a poke's message; pure, so they -//! are tested here. +//! `vm::bbcode`), mentions, event dates, a poke's message, the private +//! chats of the home sidebar; pure, so they are tested here. use chrono::{DateTime, Local, NaiveDateTime, TimeZone}; @@ -114,6 +114,17 @@ pub fn poke_message(text: &str) -> String { cut.trim_end().to_owned() } +/// The private chats of the home sidebar, by their index in `chats` +/// (newest first): at most `n`, those with unread messages first. +pub fn sidebar_dms(chats: &[crate::messages::ChatRef], n: usize) -> Vec { + let mut private: Vec = (0..chats.len()) + .filter(|&i| matches!(chats[i].target, voelin_model::ChatTarget::Private(_))) + .collect(); + private.sort_by_key(|&i| chats[i].unread == 0); + private.truncate(n); + private +} + /// The channels the search (Ctrl+K) finds for `query`, with their titles: /// a spacer by its text, never a line or an empty spacer. pub fn found_channels<'a>( @@ -273,6 +284,33 @@ mod tests { assert_eq!(found_channels(&channels, "").len(), 3); } + #[test] + fn sidebar_chats() { + use voelin_model::ChatTarget; + let chat = |target: ChatTarget, unread| crate::messages::ChatRef { + session: Some(1), + server_uid: None, + target, + last: None, + unread, + }; + let dm = |uid: &str, unread| chat(ChatTarget::Private(uid.into()), unread); + let chats = [ + dm("a", 0), + chat(ChatTarget::Server, 4), + dm("b", 2), + chat(ChatTarget::Channel(3), 1), + dm("c", 0), + dm("d", 1), + dm("e", 0), + dm("f", 0), + ]; + // Private chats only, unread first, otherwise newest first; capped. + assert_eq!(sidebar_dms(&chats, 5), [2, 5, 0, 4, 6]); + assert_eq!(sidebar_dms(&chats, 1), [2]); + assert!(sidebar_dms(&chats[1..2], 5).is_empty()); + } + #[test] fn event_dates() { let start = parse_local("2026-04-25 19:00").unwrap(); diff --git a/crates/voelin-ui/src/vm/tree.rs b/crates/voelin-ui/src/vm/tree.rs index 7189ae5..7b1051c 100644 --- a/crates/voelin-ui/src/vm/tree.rs +++ b/crates/voelin-ui/src/vm/tree.rs @@ -162,6 +162,24 @@ pub fn listed_title(channel: &ChannelInfo) -> Option<&str> { } } +/// Channels deeper than this are not followed up (a broken presence could +/// loop). +const PATH_DEPTH: usize = 64; + +/// The path of a channel, its names from the top as the server has them +/// (what an invite link names, what connecting into it takes); empty for a +/// channel the presence does not know. +pub fn channel_path(presence: &Presence, channel: ChannelId) -> Vec { + let mut names = Vec::new(); + let mut next = presence.channels.get(&channel); + while let Some(c) = next.filter(|_| names.len() < PATH_DEPTH) { + names.push(c.name.clone()); + next = presence.channels.get(&c.parent).filter(|_| c.parent != 0); + } + names.reverse(); + names +} + /// About as many characters as a fill spacer's row holds: more than the /// widest tree shows. const FILL_CHARS: usize = 200; @@ -827,4 +845,15 @@ mod tests { assert_eq!(found.len(), 1); assert!(found[0].first_in_group && found[0].group == "Guest" && found[0].group_count == 1); } + + #[test] + fn channel_paths() { + let mut p = presence(); + assert_eq!(channel_path(&p, 1), ["Lobby"], "a channel at the top"); + assert_eq!(channel_path(&p, 3), ["Games", "Chess"], "the names from the top"); + assert!(channel_path(&p, 99).is_empty(), "an unknown channel"); + // Two channels each other's parent: the path stops. + p.channels.get_mut(&2).unwrap().parent = 3; + assert_eq!(channel_path(&p, 3).len(), PATH_DEPTH); + } } diff --git a/crates/voelin-ui/ui/app.slint b/crates/voelin-ui/ui/app.slint index 1f20cb6..0c3971b 100644 --- a/crates/voelin-ui/ui/app.slint +++ b/crates/voelin-ui/ui/app.slint @@ -237,7 +237,7 @@ export component MainWindow inherits Window { : Bridge.server-title; subtitle: Nav.page == Page.settings || Nav.page == Page.friends || Nav.page == Page.messages || Nav.page == Page.library ? "" : Nav.page == Page.events || Nav.phone-voice ? Bridge.server-title - : Nav.page == Page.home || Nav.mobile-tab == MobileTab.home ? @tr("Find your people. Talk beyond.") + : Nav.page == Page.home || Nav.mobile-tab == MobileTab.home ? "" : Nav.mobile-tab == MobileTab.chat && Bridge.current-tab >= 0 && Bridge.current-tab < Bridge.tabs.length ? Bridge.tabs[Bridge.current-tab].title : Nav.mobile-tab == MobileTab.servers ? Bridge.server-stats : ""; back: Nav.page == Page.settings || Nav.page == Page.friends || Nav.page == Page.messages || Nav.page == Page.library || Nav.page == Page.events; diff --git a/crates/voelin-ui/ui/bridge.slint b/crates/voelin-ui/ui/bridge.slint index bf75d4d..c6113a9 100644 --- a/crates/voelin-ui/ui/bridge.slint +++ b/crates/voelin-ui/ui/bridge.slint @@ -522,6 +522,23 @@ export struct HappeningItem { live: bool, } +// Home's "Continue where you left off": the voice channel we were in last. +export struct ResumeItem { + // There is one: its server is still a bookmark at the same address. + shown: bool, + server-id: int, + server: string, + initials: string, + tint: color, + icon: image, + // The channel's name as the tree shows it. + channel: string, + // Voice is connected there: the button shows the server; else it + // connects into the channel. + open: bool, + connecting: bool, +} + // A scheduled event of a server's gateway. export struct EventItem { id: int, @@ -1129,8 +1146,14 @@ export global Bridge { // Home, friends, direct messages, notifications, search, events and // the settings pages. - // Home: friends online first, live streams on our servers, the latest - // chats, what friends do, events and server news, the Library. + // Home: where we were with voice last and the unread mentions (at most + // three, newest first), friends online, live streams on our servers, + // the latest chats, what friends do, events and server news, the + // Library; in the sidebar the newest private chats (five, unread + // first). + in property last-place; + in property <[NoticeItem]> home-mentions; + in property <[ConversationItem]> sidebar-dms; in property <[ContactItem]> friends-online; in property <[LiveItem]> live-rooms; in property <[ConversationItem]> recent-chats; @@ -1148,6 +1171,9 @@ export global Bridge { callback open-recordings-folder(); // Connect a bookmark with voice (the Join buttons). callback connect-server(int); + // The last place's button: its server, connected into the channel if + // voice is not there yet. + callback resume(); // Friends: the contacts (friends, then the others), the selected one. in property <[ContactItem]> contacts; diff --git a/crates/voelin-ui/ui/nav.slint b/crates/voelin-ui/ui/nav.slint index 630b413..a854237 100644 --- a/crates/voelin-ui/ui/nav.slint +++ b/crates/voelin-ui/ui/nav.slint @@ -99,6 +99,9 @@ export global Nav { // The last message shows its actions as if hovered (VOELIN_OPEN=actions: // a screenshot cannot hover). in-out property show-actions; + // Home shows its first-run banner over the servers (VOELIN_OPEN=first-run: + // the empty state over sample data). + in-out property first-run; // The bell's panel, the search (Ctrl+K) and its selected result, a // picture opened from the chat, the event and offline message forms, diff --git a/crates/voelin-ui/ui/screens/home.slint b/crates/voelin-ui/ui/screens/home.slint index e947980..ff68843 100644 --- a/crates/voelin-ui/ui/screens/home.slint +++ b/crates/voelin-ui/ui/screens/home.slint @@ -1,14 +1,18 @@ -// The home page (design mockup 01): a banner with Voelin and the user's -// servers, friends online, live streams on our servers, the servers, the -// latest chats; at the right what friends do, quick actions and what is -// happening (events, scheduled streams, server news). Also the sidebar -// that leads to Friends, Direct Messages and the Library, and the Library. +// The home page (design mockup 01): where we were with voice last and the +// unread mentions (before the first server, a banner with Voelin), friends +// online, live streams on our servers, the servers, the latest chats; at +// the right what friends do and what is happening (events, scheduled +// streams, server news). Also the sidebar that leads to Friends, Direct +// Messages and the Library, with the newest private chats; and the +// Library. import { Theme } from "../theme.slint"; import { Icons } from "../icons.slint"; -import { Bridge, ServerItem, ContactItem, LiveItem, ConversationItem, HappeningItem, RecordingItem } from "../bridge.slint"; +import { Bridge, ServerItem, ContactItem, LiveItem, ConversationItem, HappeningItem, RecordingItem, ResumeItem } from "../bridge.slint"; import { Nav, Page, SettingsSection } from "../nav.slint"; import { Icon, Button, ButtonKind, IconButton, Avatar, Status, Chip, SectionHeader, NavItem, Divider, CountBadge, LiveBadge, ScrollView, ListView } from "../components/index.slint"; +import { ConversationRow } from "messages.slint"; +import { NoticeRow } from "overlays.slint"; // A painted picture (Icons.art-*) covering an area of the given size, cut // at the sides or at the bottom by the parent's clip. Drawn at its own @@ -28,100 +32,11 @@ component Art inherits Image { image-fit: fill; } -// A quick action of the sidebar: an icon in a rounded square. -component QuickNav inherits Rectangle { - in property icon; - in property text; - callback clicked(); - height: 44px; - border-radius: Theme.radius-md; - background: touch.has-hover ? Theme.surface-3 : transparent; - accessible-role: AccessibleRole.button; - accessible-label: text; - accessible-action-default => { clicked(); } - touch := TouchArea { - mouse-cursor: MouseCursor.pointer; - clicked => { root.clicked(); } - } - HorizontalLayout { - padding-left: Theme.space-2; - spacing: Theme.space-4; - Rectangle { - width: 34px; - height: 34px; - y: (parent.height - self.height) / 2; - border-radius: Theme.radius-md; - background: Theme.surface-2; - border-width: 1px; - border-color: Theme.border-strong; - Icon { - source: root.icon; - size: Theme.icon-md; - tint: Theme.text-secondary; - } - } - Text { - text: root.text; - color: Theme.text; - vertical-alignment: center; - horizontal-stretch: 1; - overflow: elide; - } - } -} - -// The painted picture at the bottom of the home sidebar. -component SidebarArt inherits Rectangle { - min-height: 140px; - // Out to the panel's edges (over the sidebar's padding, not its - // border), so no side edges show; the top fades into the panel slowly, - // easing out. - Rectangle { - x: 1px - Theme.space-3; - width: parent.width + 2 * (Theme.space-3 - 1px); - clip: true; - Art { - source: Icons.art-sidebar; - cover-width: parent.width; - cover-height: parent.height; - align-y: 1; - } - Rectangle { - y: 0; - height: min(parent.height * 0.55, 220px); - background: @linear-gradient(180deg, - Theme.surface 0%, - Theme.surface.transparentize(0.2) 30%, - Theme.surface.transparentize(0.65) 65%, - Theme.surface.transparentize(1) 100%); - } - } - VerticalLayout { - alignment: end; - padding: Theme.space-5; - padding-bottom: Theme.space-8; - spacing: Theme.space-1; - visible: root.height > 170px; - for line in [@tr("Hang out"), @tr("Play together"), @tr("Find your people")]: Text { - text: line; - color: #e8edff; - font-size: Theme.font-lg; - font-weight: Theme.weight-medium; - } - Rectangle { - height: Theme.space-5; - } - Rectangle { - width: 44px; - height: 2px; - background: Theme.accent; - } - } -} - // The sidebar next to the home page, the friends, the messages and the -// Library. +// Library. Under its links the newest private chats, except on the +// messages page, which lists them all. export component HomeNav inherits VerticalLayout { + property dms: Nav.page != Page.messages && Bridge.sidebar-dms.length > 0; spacing: Theme.space-2; NavItem { icon: Icons.home; @@ -148,44 +63,36 @@ export component HomeNav inherits VerticalLayout { selected: Nav.page == Page.library; clicked => { Nav.show(Page.library); } } - Divider { } - VerticalLayout { - padding-top: Theme.space-3; + if root.dms: Divider { } + if root.dms: VerticalLayout { + padding-top: Theme.space-2; padding-left: Theme.space-3; - padding-bottom: Theme.space-2; Text { - text: @tr("Quick Actions"); + text: @tr("Recent Messages"); font-size: Theme.font-body; font-weight: Theme.weight-medium; color: Theme.text; } } - QuickNav { - icon: Icons.plus; - text: @tr("Add a Server"); - clicked => { Nav.add-server(); } - } - QuickNav { - icon: Icons.log-in; - text: @tr("Join a Server"); - clicked => { Nav.add-server(); } - } - QuickNav { - icon: Icons.user-plus; - text: @tr("Find Friends"); - clicked => { - Nav.friends-tab = 1; - Bridge.friends-tab(1); - Nav.show(Page.friends); + // Scrolls when the window is low, so it never makes the window taller. + if root.dms: dm-list := ScrollView { + vertical-stretch: 1; + VerticalLayout { + width: dm-list.visible-width; + alignment: start; + spacing: Theme.space-1; + for chat in Bridge.sidebar-dms: ConversationRow { + chat: chat; + } } } - SidebarArt { + if !root.dms: Rectangle { vertical-stretch: 1; } } - -// A slide arrow of the banner: a dark round button with a light ring. +// An arrow over the live streams' row: a dark round button with a light +// ring. component BannerArrow inherits Rectangle { in property icon; in property label; @@ -209,47 +116,30 @@ component BannerArrow inherits Rectangle { } } -// The banner: Voelin first, then each server; arrows and dots switch. +// The banner before the first server: Voelin, what it does, Add a Server. component HomeBanner inherits Rectangle { in property compact; - property slide: 0; - property count: Bridge.servers.length + 1; - property server: Bridge.servers[max(0, root.slide - 1)]; min-height: compact ? 200px : 212px; border-radius: Theme.radius-xl; clip: true; - background: root.slide == 0 - ? @linear-gradient(115deg, #0e1d5c 0%, #1c1470 45%, #3a1f86 75%, #0b2a6b 100%) - : @linear-gradient(115deg, root.server.tint.darker(0.6) 0%, #1c1470 55%, #0b2a6b 100%); + background: @linear-gradient(115deg, #0e1d5c 0%, #1c1470 45%, #3a1f86 75%, #0b2a6b 100%); border-width: 1px; border-color: Theme.border-strong; accessible-role: AccessibleRole.groupbox; - accessible-label: root.slide == 0 ? Bridge.app-name : root.server.name; + accessible-label: Bridge.app-name; // The night landscape, cut at the left on narrow screens (the moon - // stays); a server's slide takes the server's colour over it. + // stays). Art { source: Icons.art-banner; cover-width: parent.width; cover-height: parent.height; align-x: 1; } - if root.slide > 0: Rectangle { - background: root.server.tint.with-alpha(0.28); - } if root.compact: Rectangle { background: @linear-gradient(90deg, #060c2cc0 0%, #060c2c50 55%, transparent 85%); } - // The phone: swipe between the slides. - if root.compact && root.count > 1: SwipeGestureHandler { - handle-swipe-left: true; - handle-swipe-right: true; - swiped => { - root.slide = self.current-position.x < self.pressed-position.x - ? mod(root.slide + 1, root.count) : mod(root.slide + root.count - 1, root.count); - } - } // Words down a slope at the right, as written on the sky. - if !root.compact && root.slide == 0 && root.width > 640px: Rectangle { + if !root.compact && root.width > 640px: Rectangle { x: parent.width - 180px; y: 24px; width: 160px; @@ -268,7 +158,7 @@ component HomeBanner inherits Rectangle { padding-left: root.compact ? Theme.space-5 : 44px; spacing: Theme.space-3; alignment: center; - if root.slide == 0: HorizontalLayout { + HorizontalLayout { spacing: Theme.space-4; alignment: start; Image { @@ -284,93 +174,112 @@ component HomeBanner inherits Rectangle { vertical-alignment: center; } } - if root.slide > 0: HorizontalLayout { - spacing: Theme.space-4; - alignment: start; - Avatar { - size: root.compact ? 44px : 56px; - square: true; - initials: root.server.initials; - image: root.server.icon; - tint: root.server.tint; - label: root.server.name; - status: root.server.status == "connected" ? Status.online : root.server.status == "observing" ? Status.info : root.server.status == "connecting" ? Status.idle : Status.none; - } - Text { - text: root.server.name; - color: #ffffff; - font-size: (root.compact ? 26px : 36px) * Theme.font-scale; - font-weight: Theme.weight-bold; - vertical-alignment: center; - overflow: elide; - } - } Text { - text: root.slide == 0 ? @tr("Voice, chat and streams\non TeamSpeak servers.") - : root.server.flavor != "" ? root.server.flavor : @tr("Not reached yet"); + text: @tr("Voice, chat and streams\non TeamSpeak servers."); color: #ffffff; font-size: root.compact ? Theme.font-lg : Theme.font-2xl; font-weight: Theme.weight-medium; wrap: word-wrap; } Text { - text: root.slide == 0 ? @tr("Talk. Watch. Share. Or look in without joining.") : root.server.detail; + text: @tr("Talk. Watch. Share. Or look in without joining."); color: #c9d4ff; wrap: word-wrap; } HorizontalLayout { alignment: start; - spacing: Theme.space-3; padding-top: Theme.space-2; - if root.slide == 0: Button { + Button { kind: ButtonKind.primary; icon: Icons.arrow-right; text: @tr("Add a Server"); clicked => { Nav.add-server(); } } - if root.slide > 0 && root.server.status != "connected": Button { - kind: ButtonKind.primary; - icon: Icons.log-in; - text: root.server.status == "connecting" ? @tr("Connecting…") : @tr("Connect"); - enabled: root.server.status != "connecting"; - clicked => { Bridge.connect-server(root.server.id); } - } - if root.slide > 0: Button { - icon: Icons.arrow-right; - text: @tr("Open"); - clicked => { Nav.select-server(root.server.id); } - } } } - // Round buttons in the bottom corners, a little above the dots. The - // phone has the dots only. - if root.count > 1 && !root.compact: BannerArrow { - x: Theme.space-3; - y: parent.height - self.height - 12px; - icon: Icons.chevron-left; - label: @tr("Previous"); - clicked => { root.slide = mod(root.slide + root.count - 1, root.count); } +} + +// Where we were with voice last: the channel and its server, Join (Open +// while voice is there). +component ResumeCard inherits Rectangle { + in property place; + in property compact; + border-radius: Theme.radius-lg; + clip: true; + background: Theme.surface-2; + border-width: 1px; + border-color: touch.has-hover ? Theme.border-strong : Theme.border; + accessible-role: AccessibleRole.groupbox; + accessible-label: @tr("Continue where you left off"); + accessible-description: place.channel + " · " + place.server; + touch := TouchArea { + mouse-cursor: MouseCursor.pointer; + enabled: !root.place.connecting; + clicked => { Bridge.resume(); } } - if root.count > 1 && !root.compact: BannerArrow { - x: parent.width - self.width - Theme.space-3; - y: parent.height - self.height - 12px; - icon: Icons.chevron-right; - label: @tr("Next"); - clicked => { root.slide = mod(root.slide + 1, root.count); } + // The server's colour, fading out to the right. + Rectangle { + background: @linear-gradient(90deg, root.place.tint.with-alpha(0.3) 0%, root.place.tint.with-alpha(0) 65%); } - if root.count > 1: HorizontalLayout { - y: parent.height - (root.compact ? 22px : 17px); - height: 10px; - alignment: center; - spacing: Theme.space-3; - for i in root.count: Rectangle { - width: 8px; - height: 8px; - border-radius: 4px; - background: i == root.slide ? #ffffff : #ffffff50; - TouchArea { - mouse-cursor: MouseCursor.pointer; - clicked => { root.slide = i; } + HorizontalLayout { + padding: root.compact ? Theme.space-3 : Theme.space-4; + padding-left: root.compact ? Theme.space-3 : Theme.space-5; + spacing: root.compact ? Theme.space-3 : Theme.space-4; + VerticalLayout { + alignment: center; + Avatar { + size: root.compact ? 44px : 52px; + square: true; + initials: root.place.initials; + image: root.place.icon; + tint: root.place.tint; + label: root.place.server; + status: root.place.open ? Status.online : root.place.connecting ? Status.idle : Status.none; + } + } + VerticalLayout { + alignment: center; + horizontal-stretch: 1; + spacing: 2px; + Text { + text: @tr("Continue where you left off"); + color: Theme.text-muted; + font-size: Theme.font-xs; + overflow: elide; + } + HorizontalLayout { + spacing: Theme.space-2; + Icon { + source: Icons.channel; + size: Theme.icon-sm; + tint: Theme.text-secondary; + y: (parent.height - self.height) / 2; + } + Text { + text: root.place.channel; + color: Theme.text; + font-size: root.compact ? Theme.font-md : Theme.font-lg; + font-weight: Theme.weight-semibold; + horizontal-stretch: 1; + overflow: elide; + } + } + Text { + text: root.place.server; + color: Theme.text-secondary; + font-size: Theme.font-sm; + overflow: elide; + } + } + VerticalLayout { + alignment: center; + Button { + small: root.compact; + kind: root.place.open ? ButtonKind.secondary : ButtonKind.primary; + icon: root.place.open ? Icons.arrow-right : Icons.log-in; + text: root.place.connecting ? @tr("Connecting…") : root.place.open ? @tr("Open") : @tr("Join"); + enabled: !root.place.connecting; + clicked => { Bridge.resume(); } } } } @@ -889,8 +798,14 @@ component ActivityRow inherits Rectangle { // The main column of the home page. export component HomePage inherits Rectangle { - // The phone layout: one column with the messages and the activity. + // The phone layout: one column with the messages and the servers. in property compact; + // No server yet (or VOELIN_OPEN=first-run): the banner with Add a + // Server, in place of where we were last and the mentions. + property first-run: Bridge.servers.length == 0 || Nav.first-run; + // Friends once: the bubbles where the right column with what friends + // do is hidden. + property bubbles: root.compact || !Nav.wide; // The column inside its padding; a friend's bubble and the gap after it. property row-width: sv.visible-width - 2 * Theme.space-4; property friend-gap: 6px; @@ -905,10 +820,26 @@ export component HomePage inherits Rectangle { padding: Theme.space-4; spacing: Theme.space-4; alignment: start; - HomeBanner { + if root.first-run: HomeBanner { compact: root.compact; } - Section { + if !root.first-run && Bridge.last-place.shown: ResumeCard { + place: Bridge.last-place; + compact: root.compact; + } + if !root.first-run && Bridge.home-mentions.length > 0: Section { + text: @tr("Unread Mentions"); + icon: Icons.at-sign; + action: @tr("See All"); + action-clicked => { Nav.notifications-open = true; } + } + if !root.first-run && Bridge.home-mentions.length > 0: VerticalLayout { + spacing: Theme.space-1; + for notice in Bridge.home-mentions: NoticeRow { + notice: notice; + } + } + if root.bubbles: Section { text: @tr("Friends Online"); icon: Icons.users; action: @tr("View All ({})", Bridge.friends-online.length); @@ -918,13 +849,13 @@ export component HomePage inherits Rectangle { Nav.show(Page.friends); } } - if Bridge.friends-online.length == 0: Text { + if root.bubbles && Bridge.friends-online.length == 0: Text { text: @tr("No friends online. Add friends from a person's card on a server: they show up here, wherever they are."); color: Theme.text-muted; font-size: Theme.font-sm; wrap: word-wrap; } - if Bridge.friends-online.length > 0: HorizontalLayout { + if root.bubbles && Bridge.friends-online.length > 0: HorizontalLayout { spacing: root.friend-gap; alignment: start; // On the desktop as many whole bubbles as fit (the rest @@ -1090,78 +1021,6 @@ export component HomePage inherits Rectangle { chat: chat; } } - if root.compact: Section { - text: @tr("Recent Activity"); - icon: Icons.zap; - action: @tr("See All"); - action-clicked => { Nav.show(Page.friends); } - } - if root.compact: VerticalLayout { - spacing: Theme.space-1; - for friend in Bridge.friend-activity: ActivityRow { - friend: friend; - } - } - } - } -} - -// A quick action of the right column: an icon, a title and what it does. -component QuickAction inherits Rectangle { - in property icon; - in property title; - in property subtitle; - callback clicked(); - height: 54px; - border-radius: Theme.radius-md; - background: touch.has-hover ? Theme.surface-3 : Theme.surface-2; - border-width: 1px; - border-color: Theme.border; - accessible-role: AccessibleRole.button; - accessible-label: title; - accessible-description: subtitle; - accessible-action-default => { clicked(); } - touch := TouchArea { - mouse-cursor: MouseCursor.pointer; - clicked => { root.clicked(); } - } - HorizontalLayout { - padding-left: Theme.space-3; - padding-right: Theme.space-3; - spacing: Theme.space-3; - Rectangle { - width: 36px; - height: 36px; - y: (parent.height - self.height) / 2; - border-radius: 18px; - background: Theme.accent-soft; - Icon { - source: root.icon; - size: Theme.icon-md; - tint: Theme.accent-text; - } - } - VerticalLayout { - alignment: center; - horizontal-stretch: 1; - Text { - text: root.title; - color: Theme.text; - font-weight: Theme.weight-medium; - overflow: elide; - } - Text { - text: root.subtitle; - color: Theme.text-muted; - font-size: Theme.font-xs; - overflow: elide; - } - } - Icon { - source: Icons.chevron-right; - size: Theme.icon-sm; - tint: Theme.text-muted; - y: (parent.height - self.height) / 2; } } } @@ -1262,32 +1121,6 @@ export component HomeAside inherits Rectangle { } } Divider { } - Section { - text: @tr("Quick Actions"); - } - QuickAction { - icon: Icons.user-plus; - title: @tr("Find Friends"); - subtitle: @tr("Search your contacts"); - clicked => { - Nav.friends-tab = 1; - Bridge.friends-tab(1); - Nav.show(Page.friends); - } - } - QuickAction { - icon: Icons.log-in; - title: @tr("Join a Server"); - subtitle: @tr("Enter an address"); - clicked => { Nav.add-server(); } - } - QuickAction { - icon: Icons.bookmark; - title: @tr("Add a Server"); - subtitle: @tr("Save it for later"); - clicked => { Nav.add-server(); } - } - Divider { } Section { text: @tr("What's Happening"); } diff --git a/crates/voelin-ui/ui/screens/messages.slint b/crates/voelin-ui/ui/screens/messages.slint index 0f3810e..3df57db 100644 --- a/crates/voelin-ui/ui/screens/messages.slint +++ b/crates/voelin-ui/ui/screens/messages.slint @@ -11,8 +11,8 @@ import { Nav, Page } from "../nav.slint"; import { Icon, Button, ButtonKind, IconButton, Avatar, Status, Chip, CountBadge, SearchBox, TextField, Field, Slider, Divider, Banner, Modal, PopupMenu, MenuEntry, ListView, ScrollView } from "../components/index.slint"; import { MessageList, Composer } from "chat.slint"; -// One conversation of the list. -component ConversationRow inherits Rectangle { +// One conversation of the list (also the home sidebar's). +export component ConversationRow inherits Rectangle { in property chat; height: 64px * Theme.font-scale; border-radius: Theme.radius-md; diff --git a/crates/voelin-ui/ui/screens/overlays.slint b/crates/voelin-ui/ui/screens/overlays.slint index b12fe95..7e2a97f 100644 --- a/crates/voelin-ui/ui/screens/overlays.slint +++ b/crates/voelin-ui/ui/screens/overlays.slint @@ -7,8 +7,8 @@ import { Bridge, NoticeItem, SearchItem } from "../bridge.slint"; import { Nav, Page, SettingsSection } from "../nav.slint"; import { Icon, Button, ButtonKind, IconButton, Avatar, Status, Chip, CountBadge, TextField, Kbd, Divider, ScrollView } from "../components/index.slint"; -// One notification. -component NoticeRow inherits Rectangle { +// One notification (also home's unread mentions). +export component NoticeRow inherits Rectangle { in property notice; // Never shorter than its text, so a long list scrolls instead of // squeezing the rows. diff --git a/docs/ui.md b/docs/ui.md index 5162da2..e75c7ab 100644 --- a/docs/ui.md +++ b/docs/ui.md @@ -179,7 +179,7 @@ where a server has it. | Part | `VOELIN_OPEN` | What it shows | Engine data | |---|---|---|---| -| Home | `home` | A banner with Voelin and a slide per server (connect, open); friends online (as many whole bubbles as fit, Find Friends after them); live streams on our servers (any channel, the gateways' directories, clients flagged streaming) with viewers, server, channel and kind; our servers with who is there and Join or Open; the latest chats of every server. At the right what friends do, quick actions (find friends, and join or add a server: both open the add-server dialog) and what is happening (gateway events and scheduled streams, soonest first, then server news). The phone has the messages, servers, live streams and recent activity in one column | `FriendPresence`, `ContactsChanged`, `StreamsChanged`, `Gateway` (stream directory, events), `Presence` (the servers' welcome and host messages), `History::recent_chats` | +| Home | `home`, `first-run` | Before the first server a banner with Voelin and Add a Server; after it "Continue where you left off": the voice channel we were in last (`ui.last_voice`, kept when our channel changes) with Join, which connects into it, or Open while voice is there (none once its server is deleted or has another address), and up to three unread mentions (they open their chat). Then friends online where the right column is hidden (as many whole bubbles as fit, Find Friends after them); live streams on our servers (any channel, the gateways' directories, clients flagged streaming) with viewers, server, channel and kind; our servers with who is there and Join or Open; the latest chats of every server. At the right what friends do and what is happening (gateway events and scheduled streams, soonest first, then server news). The sidebar lists the five newest private chats, unread first (not on the messages page). The phone has the messages, servers and live streams in one column after the friends | `State` (our channel), `FriendPresence`, `ContactsChanged`, `StreamsChanged`, `Gateway` (stream directory, events), `Presence` (the servers' welcome and host messages), `Chat` (mentions), `History::recent_chats` | | Library | `library` | The Stream Studio's recordings and clips (the files in `studio.recording_dir`, newest first) with Play and Open Folder | the folder | | Friends | `friends[:]` | Online, All and Blocked tabs, a search; each contact with where they are (server, channel, away, live), message, poke, join, watch. The selected one at the right: relation, where, a note, our volume and mute for them, friend, block, forget | `ContactsChanged`, `FriendPresence`; `Command::SetContact`, `RemoveContact`, `Poke`, `MoveToChannel` | | Direct messages | `messages[:]`, `inbox`, `offline` | The private chats of every server and of the store (peers by unique id) with the last message and unread counts, All, Unread and Inbox (offline messages); the conversation with the chat's message list, pokes among the messages, pictures and files, a composer, and a clear state when the peer cannot be reached (an offline message instead, where the server keeps them); the peer at the right: relation, note, the servers they are on, shared pictures and files, our volume for them | `ChatHistory` (`ChatTarget::Private` by unique id), `Command::LoadOlderHistory`, `Poke`, offline messages (`ListOfflineMessages`, `GetOfflineMessage`, `SendOfflineMessage`, `DeleteOfflineMessage`, `SetOfflineMessageRead`) | @@ -318,9 +318,9 @@ then Cancel, Save and Connect. Save keeps the server. Connect, also Enter in the address or password field, keeps it, connects it with voice and shows it (`Bridge.save-and-connect`, `App::save_and_connect`): nothing connects when saving failed. While the server has voice, Connect is hidden and Save is the -main button. Home's Join a Server and Add a Server both open this dialog. The -form also carries a channel, its password and a privilege key for TeamSpeak -links, which are not stored with the server: with a channel the dialog shows +main button. Home's Add a Server opens this dialog too. The form also +carries a channel, its password and a privilege key for TeamSpeak links, +which are not stored with the server: with a channel the dialog shows "Joins " and Connect connects into it; with a key it shows "This link grants a server group". @@ -448,7 +448,8 @@ Environment variables (see `src/dev.rs`): `about`, `share[:live]`, `bookmark[:edit]`, `emoji`, `client`, `panel`, `no-panel`, `voice`, `pins`, `topics`, `topic:`, `member`, `poke`, `channel-password[:wrong]`, `actions` (the last message's actions, as if - hovered: a screenshot cannot hover), `link-confirm[:]` (the question + hovered: a screenshot cannot hover), `first-run` (Home's banner as before + the first server, over the sample data), `link-confirm[:]` (the question before a masked link opens, by default the sample's), `unread` (the current chat read up to five messages before its end: the New line, scrolled up to; `unread:end` ten messages before, at the end of the list,