ui: home continues where you left off, with unread mentions

The banner carousel repeated the servers below it, and the quick actions,
the friends and the sidebar art appeared twice. Home now shows the banner
only before the first server; after it a card with the last voice channel
(`ui.last_voice`, Join or Open) and up to three unread mentions. Friends
show once, and the sidebar lists the five newest private chats.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AVRENKftQqGoEeswiR9TDQ
This commit is contained in:
Claude committed 2026-10-07 15:40:34 +00:00
1 parent a3b61bca70
commit 7965187d2c
20 files changed
+561 -372

No files matched your search

+7 -3
View File
@@ -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, - 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 which stay in place; the Older messages button remains for a chat that
fits on the screen. fits on the screen.
- One dialog adds a server, with Save and Connect (Enter connects); Home's - One dialog adds a server, with Save and Connect (Enter connects).
Join a Server opens it too. Connect connects only a server it saved (Join Connect connects only a server it saved (Join connected the server shown
connected the server shown before when saving failed). before when saving failed).
- A slimmer top bar on desktop: only the search and the bell. The bell's - 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 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 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 Settings. The user card has no settings gear (the rail's stays); its
avatar and name open your account. 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 ### Fixed
+17
View File
@@ -1022,6 +1022,7 @@ impl App {
let view = self.sessions.entry(id).or_default(); let view = self.sessions.entry(id).or_default();
let was_voice = view.state.voice; let was_voice = view.state.voice;
let was_observe = view.state.observe; let was_observe = view.state.observe;
let was_channel = view.state.own_channel;
view.state = state.clone(); view.state = state.clone();
if state.voice != VoiceState::Connected { if state.voice != VoiceState::Connected {
view.focused_own_channel = false; view.focused_own_channel = false;
@@ -1060,6 +1061,12 @@ impl App {
self.sessions.entry(id).or_default().focused_own_channel = true; 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_servers();
self.refresh_toolbar(); self.refresh_toolbar();
self.refresh_tree(); self.refresh_tree();
@@ -1090,9 +1097,19 @@ impl App {
// their pictures. // their pictures.
let said = crate::chat::server_texts(&view.presence.server) let said = crate::chat::server_texts(&view.presence.server)
!= crate::chat::server_texts(&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; view.presence = presence;
let renamed = path(view) != path_before;
self.apply_client_playback(session as i64); self.apply_client_playback(session as i64);
self.join_after_connect(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 self.current == Some(session as i64) {
if said { if said {
self.fetch_previews(session as i64); self.fetch_previews(session as i64);
+3
View File
@@ -26,6 +26,9 @@ pub(super) fn wire(ui: &MainWindow) {
bridge.on_connect_server(|id| { bridge.on_connect_server(|id| {
with_app(|app| app.connect_server(i64::from(id))); with_app(|app| app.connect_server(i64::from(id)));
}); });
bridge.on_resume(|| {
with_app(|app| app.resume());
});
// Friends. // Friends.
bridge.on_friends_tab(|tab| { bridge.on_friends_tab(|tab| {
+23 -3
View File
@@ -28,6 +28,8 @@
//! `channel-password` (the password dialog of the first locked channel, //! `channel-password` (the password dialog of the first locked channel,
//! the sample's Officers; `channel-password:wrong` as after a refused //! the sample's Officers; `channel-password:wrong` as after a refused
//! one), `actions` (the last message's actions, as if hovered), //! 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: //! `unread` (the current chat read up to five messages before its end:
//! the "New" divider, scrolled up to; `unread:end` ten messages before, //! the "New" divider, scrolled up to; `unread:end` ten messages before,
//! at the list's end, under the bar that counts the new messages), //! 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::{ use crate::app::{
App, Bridge, MainWindow, MobileTab, Nav, Page, RecordingItem, SettingsSection, with_app, App, Bridge, MainWindow, MobileTab, Nav, Page, RecordingItem, SettingsSection, with_app,
}; };
use crate::settings::LastVoice;
/// The switches read at start. /// The switches read at start.
#[derive(Clone, Debug, Default)] #[derive(Clone, Debug, Default)]
@@ -294,6 +297,8 @@ pub(crate) fn start(ui: &MainWindow, switches: &Switches) -> Running {
} }
// A screenshot cannot hover. // A screenshot cannot hover.
"actions" => nav.set_show_actions(true), "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. // `end`: further back, so the divider is above the view.
"unread" => { "unread" => {
with_app(|app| open_unread(app, if arg == "end" { 10 } else { 5 })); 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 + 1, "Pixel Lounge", "pixel.example"),
bookmark(DEMO + 2, "Dev TS3", "127.0.0.1:9987"), 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); app.current = Some(DEMO);
let session = DEMO as u64; 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 // Notifications: two mentions (unread: home shows them), a message, an
// the poke above). // event, a friend online (and the poke above).
use crate::social::{NoticeKind, NoticeTarget}; use crate::social::{NoticeKind, NoticeTarget};
app.notify( app.notify(
NoticeKind::Mention, NoticeKind::Mention,
@@ -1106,6 +1118,14 @@ fn demo_social(app: &mut App) {
"Talon".into(), "Talon".into(),
Some("demo-6".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( app.notify(
NoticeKind::Event, NoticeKind::Event,
"Late Night Lofi & Chat starts in 50 min".into(), "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() { for (i, n) in app.social.notices.iter_mut().enumerate() {
n.ts_ms = now - (i as i64 * 9 + 2) * min; 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(); app.refresh_notices();
+66 -5
View File
@@ -1,15 +1,20 @@
//! The home page (design mockup 01): live streams on our servers, what is //! The home page (design mockup 01): where we were with voice last, live
//! happening there (events, scheduled streams, server news), and the //! streams on our servers, what is happening there (events, scheduled
//! Library of recordings and clips. Friends are in `social.rs`, the recent //! streams, server news), and the Library of recordings and clips.
//! chats in `messages.rs`. //! Friends and the unread mentions are in `social.rs`, the recent chats in
//! `messages.rs`.
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use slint::ComponentHandle; use slint::ComponentHandle;
use voelin_core::VoiceState; 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;
use crate::vm::home::ResumeAction;
use crate::vm::social::{event_when, plain}; use crate::vm::social::{event_when, plain};
/// What a "What's Happening" entry opens. /// What a "What's Happening" entry opens.
@@ -240,6 +245,62 @@ impl App {
self.connect_voice(); self.connect_voice();
} }
fn last_resume(&self) -> Option<vm::home::Resume> {
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. /// The folder of recordings and clips.
fn recordings_dir(&self) -> PathBuf { fn recordings_dir(&self) -> PathBuf {
voelin_core::studio::recording_dir(&self.prefs) voelin_core::studio::recording_dir(&self.prefs)
+14 -4
View File
@@ -1,7 +1,7 @@
//! Direct messages (design mockup 02) and the recent chats of the home //! 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 //! page and its sidebar: every chat the sessions hold and the newest ones
//! store, across servers; the open private chat with who it is with; TS3 //! in the history store, across servers; the open private chat with who it
//! and TS6 offline messages (mail the server keeps). //! is with; TS3 and TS6 offline messages (mail the server keeps).
//! //!
//! A private chat is a chat tab of its session (`ChatTarget::Private` //! 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 //! 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) { fn refresh_conversations(&self) {
let Some(ui) = self.ui.upgrade() else { return }; let Some(ui) = self.ui.upgrade() else { return };
let bridge = ui.global::<Bridge>(); let bridge = ui.global::<Bridge>();
@@ -251,6 +252,15 @@ impl App {
.map(|(i, c)| self.conversation_item(i, c)) .map(|(i, c)| self.conversation_item(i, c))
.collect(); .collect();
vm::list::sync(&self.models.social.recent, &recent); vm::list::sync(&self.models.social.recent, &recent);
// Shown beside other pages: none is the open one.
let sidebar: Vec<ConversationItem> = 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 private = |c: &&ChatRef| matches!(c.target, ChatTarget::Private(_));
let items: Vec<ConversationItem> = if dm.tab == 2 { let items: Vec<ConversationItem> = if dm.tab == 2 {
dm.inbox dm.inbox
+7 -12
View File
@@ -397,6 +397,7 @@ impl App {
}) })
.collect(); .collect();
vm::list::sync(&self.models.servers, &items); 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_current_server(self.current.map_or(-1, |id| id as i32));
bridge.set_unread_total(self.view().map_or(0, |v| v.unread())); 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 { pub(crate) fn invite_link(&mut self) -> String {
let bookmark = self.current.and_then(|id| self.bookmark(id)).map(|b| b.address.clone()); let bookmark = self.current.and_then(|id| self.bookmark(id)).map(|b| b.address.clone());
let path = self.view().and_then(|v| { let path = self.view().and_then(|v| {
let mut names = Vec::new(); let cid = v.state.own_channel?;
let own = v.presence.channels.get(&v.state.own_channel?)?; let own = v.presence.channels.get(&cid)?;
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();
// The link names the channels as the server has them; the // The link names the channels as the server has them; the
// toast as the tree shows them. // 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 { let (Some(address), Some((path, title))) = (bookmark, path) else {
self.set_status("Join a voice channel to invite others to it"); self.set_status("Join a voice channel to invite others to it");
+23
View File
@@ -271,6 +271,9 @@ pub struct UiSettings {
/// "Continue without an account" was chosen on the login page: it does /// "Continue without an account" was chosen on the login page: it does
/// not show at start any more (signing in clears it). /// not show at start any more (signing in clears it).
pub skip_account_prompt: bool, pub skip_account_prompt: bool,
/// The voice channel we were in last (Home's "Continue where you left
/// off").
pub last_voice: Option<LastVoice>,
} }
impl Default for UiSettings { impl Default for UiSettings {
@@ -283,10 +286,21 @@ impl Default for UiSettings {
share: ShareDefaults::default(), share: ShareDefaults::default(),
crash_reports: false, crash_reports: false,
skip_account_prompt: 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<String>,
}
/// The last choices in the share dialog. Frame rate and bitrate are the /// The last choices in the share dialog. Frame rate and bitrate are the
/// settings `stream.fps` and `stream.bitrate_kbps`; the indices of the /// settings `stream.fps` and `stream.bitrate_kbps`; the indices of the
/// closest choices of the old lists ([`LEGACY_FPS_CHOICES`], /// 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!(!parsed.crash_reports, "crash reports are opt-in");
assert_eq!(parsed.ptt_key, "Ctrl+Shift+T"); assert_eq!(parsed.ptt_key, "Ctrl+Shift+T");
assert_eq!(parsed.share, ShareDefaults::default()); 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::<UiSettings>(&json).unwrap().last_voice, Some(last));
assert_eq!(serde_json::to_value(ThemeChoice::System).unwrap(), "system"); assert_eq!(serde_json::to_value(ThemeChoice::System).unwrap(), "system");
assert_eq!(ThemeChoice::parse("light"), ThemeChoice::Light); assert_eq!(ThemeChoice::parse("light"), ThemeChoice::Light);
assert_eq!(ThemeChoice::parse("??"), ThemeChoice::Dark); assert_eq!(ThemeChoice::parse("??"), ThemeChoice::Dark);
+28 -17
View File
@@ -169,11 +169,13 @@ pub(crate) struct SocialModels {
pub blocked: Rc<VecModel<ContactItem>>, pub blocked: Rc<VecModel<ContactItem>>,
pub live: Rc<VecModel<LiveItem>>, pub live: Rc<VecModel<LiveItem>>,
pub recent: Rc<VecModel<ConversationItem>>, pub recent: Rc<VecModel<ConversationItem>>,
pub sidebar_dms: Rc<VecModel<ConversationItem>>,
pub conversations: Rc<VecModel<ConversationItem>>, pub conversations: Rc<VecModel<ConversationItem>>,
pub dm_lines: Rc<VecModel<ChatLine>>, pub dm_lines: Rc<VecModel<ChatLine>>,
pub happenings: Rc<VecModel<HappeningItem>>, pub happenings: Rc<VecModel<HappeningItem>>,
pub recordings: Rc<VecModel<RecordingItem>>, pub recordings: Rc<VecModel<RecordingItem>>,
pub notices: Rc<VecModel<NoticeItem>>, pub notices: Rc<VecModel<NoticeItem>>,
pub mentions: Rc<VecModel<NoticeItem>>,
pub search: Rc<VecModel<SearchItem>>, pub search: Rc<VecModel<SearchItem>>,
pub events: Rc<VecModel<crate::app::EventItem>>, pub events: Rc<VecModel<crate::app::EventItem>>,
} }
@@ -187,11 +189,13 @@ impl SocialModels {
blocked: Rc::default(), blocked: Rc::default(),
live: Rc::default(), live: Rc::default(),
recent: Rc::default(), recent: Rc::default(),
sidebar_dms: Rc::default(),
conversations: Rc::default(), conversations: Rc::default(),
dm_lines: Rc::default(), dm_lines: Rc::default(),
happenings: Rc::default(), happenings: Rc::default(),
recordings: Rc::default(), recordings: Rc::default(),
notices: Rc::default(), notices: Rc::default(),
mentions: Rc::default(),
search: Rc::default(), search: Rc::default(),
events: Rc::default(), events: Rc::default(),
}; };
@@ -201,11 +205,13 @@ impl SocialModels {
bridge.set_blocked(ModelRc::from(m.blocked.clone())); bridge.set_blocked(ModelRc::from(m.blocked.clone()));
bridge.set_live_rooms(ModelRc::from(m.live.clone())); bridge.set_live_rooms(ModelRc::from(m.live.clone()));
bridge.set_recent_chats(ModelRc::from(m.recent.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_conversations(ModelRc::from(m.conversations.clone()));
bridge.set_dm_messages(ModelRc::from(m.dm_lines.clone())); bridge.set_dm_messages(ModelRc::from(m.dm_lines.clone()));
bridge.set_happenings(ModelRc::from(m.happenings.clone())); bridge.set_happenings(ModelRc::from(m.happenings.clone()));
bridge.set_recordings(ModelRc::from(m.recordings.clone())); bridge.set_recordings(ModelRc::from(m.recordings.clone()));
bridge.set_notifications(ModelRc::from(m.notices.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_search_results(ModelRc::from(m.search.clone()));
bridge.set_events(ModelRc::from(m.events.clone())); bridge.set_events(ModelRc::from(m.events.clone()));
m m
@@ -630,26 +636,31 @@ impl App {
self.refresh_notices(); self.refresh_notices();
} }
/// The bell's notices, and home's unread mentions (the newest three).
pub(crate) fn refresh_notices(&self) { pub(crate) fn refresh_notices(&self) {
let Some(ui) = self.ui.upgrade() else { return }; let Some(ui) = self.ui.upgrade() else { return };
let items: Vec<NoticeItem> = self let item = |n: &Notice| NoticeItem {
.social key: n.key,
.notices kind: n.kind.name().into(),
.iter() title: n.title.clone().into(),
.map(|n| NoticeItem { body: n.body.clone().into(),
key: n.key, time: ago(n.ts_ms).into(),
kind: n.kind.name().into(), unread: n.unread,
title: n.title.clone().into(), initials: vm::avatar::initials(&n.name).into(),
body: n.body.clone().into(), tint: vm::avatar::tint(&n.name),
time: ago(n.ts_ms).into(), avatar: n.uid.as_deref().map(|u| self.avatar_of(u)).unwrap_or_default(),
unread: n.unread, };
initials: vm::avatar::initials(&n.name).into(), let notices = &self.social.notices;
tint: vm::avatar::tint(&n.name), let items: Vec<NoticeItem> = notices.iter().map(item).collect();
avatar: n.uid.as_deref().map(|u| self.avatar_of(u)).unwrap_or_default(),
})
.collect();
vm::list::sync(&self.models.social.notices, &items); vm::list::sync(&self.models.social.notices, &items);
let unread = self.social.notices.iter().filter(|n| n.unread).count(); let mentions: Vec<NoticeItem> = 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::<Bridge>().set_notifications_unread(unread as i32); ui.global::<Bridge>().set_notifications_unread(unread as i32);
} }
+114
View File
@@ -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<String>,
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<Resume> {
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");
}
}
+1
View File
@@ -6,6 +6,7 @@
pub mod avatar; pub mod avatar;
pub mod bbcode; pub mod bbcode;
pub mod chat; pub mod chat;
pub mod home;
pub mod list; pub mod list;
pub mod servers; pub mod servers;
pub mod social; pub mod social;
+40 -2
View File
@@ -1,7 +1,7 @@
//! Texts of the home, friends, messages, bell and events screens: times //! Texts of the home, friends, messages, bell and events screens: times
//! ("12m ago", "Yesterday"), message previews without BBCode (read by //! ("12m ago", "Yesterday"), message previews without BBCode (read by
//! `vm::bbcode`), mentions, event dates, a poke's message; pure, so they //! `vm::bbcode`), mentions, event dates, a poke's message, the private
//! are tested here. //! chats of the home sidebar; pure, so they are tested here.
use chrono::{DateTime, Local, NaiveDateTime, TimeZone}; use chrono::{DateTime, Local, NaiveDateTime, TimeZone};
@@ -114,6 +114,17 @@ pub fn poke_message(text: &str) -> String {
cut.trim_end().to_owned() 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<usize> {
let mut private: Vec<usize> = (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: /// The channels the search (Ctrl+K) finds for `query`, with their titles:
/// a spacer by its text, never a line or an empty spacer. /// a spacer by its text, never a line or an empty spacer.
pub fn found_channels<'a>( pub fn found_channels<'a>(
@@ -273,6 +284,33 @@ mod tests {
assert_eq!(found_channels(&channels, "").len(), 3); 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] #[test]
fn event_dates() { fn event_dates() {
let start = parse_local("2026-04-25 19:00").unwrap(); let start = parse_local("2026-04-25 19:00").unwrap();
+29
View File
@@ -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<String> {
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 /// About as many characters as a fill spacer's row holds: more than the
/// widest tree shows. /// widest tree shows.
const FILL_CHARS: usize = 200; const FILL_CHARS: usize = 200;
@@ -827,4 +845,15 @@ mod tests {
assert_eq!(found.len(), 1); assert_eq!(found.len(), 1);
assert!(found[0].first_in_group && found[0].group == "Guest" && found[0].group_count == 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);
}
} }
+1 -1
View File
@@ -237,7 +237,7 @@ export component MainWindow inherits Window {
: Bridge.server-title; : Bridge.server-title;
subtitle: Nav.page == Page.settings || Nav.page == Page.friends || Nav.page == Page.messages || Nav.page == Page.library ? "" 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.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.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 : ""; : 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; back: Nav.page == Page.settings || Nav.page == Page.friends || Nav.page == Page.messages || Nav.page == Page.library || Nav.page == Page.events;
+28 -2
View File
@@ -522,6 +522,23 @@ export struct HappeningItem {
live: bool, 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. // A scheduled event of a server's gateway.
export struct EventItem { export struct EventItem {
id: int, id: int,
@@ -1129,8 +1146,14 @@ export global Bridge {
// Home, friends, direct messages, notifications, search, events and // Home, friends, direct messages, notifications, search, events and
// the settings pages. // the settings pages.
// Home: friends online first, live streams on our servers, the latest // Home: where we were with voice last and the unread mentions (at most
// chats, what friends do, events and server news, the Library. // 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 <ResumeItem> last-place;
in property <[NoticeItem]> home-mentions;
in property <[ConversationItem]> sidebar-dms;
in property <[ContactItem]> friends-online; in property <[ContactItem]> friends-online;
in property <[LiveItem]> live-rooms; in property <[LiveItem]> live-rooms;
in property <[ConversationItem]> recent-chats; in property <[ConversationItem]> recent-chats;
@@ -1148,6 +1171,9 @@ export global Bridge {
callback open-recordings-folder(); callback open-recordings-folder();
// Connect a bookmark with voice (the Join buttons). // Connect a bookmark with voice (the Join buttons).
callback connect-server(int); 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. // Friends: the contacts (friends, then the others), the selected one.
in property <[ContactItem]> contacts; in property <[ContactItem]> contacts;
+3
View File
@@ -99,6 +99,9 @@ export global Nav {
// The last message shows its actions as if hovered (VOELIN_OPEN=actions: // The last message shows its actions as if hovered (VOELIN_OPEN=actions:
// a screenshot cannot hover). // a screenshot cannot hover).
in-out property <bool> show-actions; in-out property <bool> show-actions;
// Home shows its first-run banner over the servers (VOELIN_OPEN=first-run:
// the empty state over sample data).
in-out property <bool> first-run;
// The bell's panel, the search (Ctrl+K) and its selected result, a // The bell's panel, the search (Ctrl+K) and its selected result, a
// picture opened from the chat, the event and offline message forms, // picture opened from the chat, the event and offline message forms,
+147 -314
View File
@@ -1,14 +1,18 @@
// The home page (design mockup 01): a banner with Voelin and the user's // The home page (design mockup 01): where we were with voice last and the
// servers, friends online, live streams on our servers, the servers, the // unread mentions (before the first server, a banner with Voelin), friends
// latest chats; at the right what friends do, quick actions and what is // online, live streams on our servers, the servers, the latest chats; at
// happening (events, scheduled streams, server news). Also the sidebar // the right what friends do and what is happening (events, scheduled
// that leads to Friends, Direct Messages and the Library, and the Library. // 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 { Theme } from "../theme.slint";
import { Icons } from "../icons.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 { 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 { 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 // 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 // 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; image-fit: fill;
} }
// A quick action of the sidebar: an icon in a rounded square.
component QuickNav inherits Rectangle {
in property <image> icon;
in property <string> 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 // 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 { export component HomeNav inherits VerticalLayout {
property <bool> dms: Nav.page != Page.messages && Bridge.sidebar-dms.length > 0;
spacing: Theme.space-2; spacing: Theme.space-2;
NavItem { NavItem {
icon: Icons.home; icon: Icons.home;
@@ -148,44 +63,36 @@ export component HomeNav inherits VerticalLayout {
selected: Nav.page == Page.library; selected: Nav.page == Page.library;
clicked => { Nav.show(Page.library); } clicked => { Nav.show(Page.library); }
} }
Divider { } if root.dms: Divider { }
VerticalLayout { if root.dms: VerticalLayout {
padding-top: Theme.space-3; padding-top: Theme.space-2;
padding-left: Theme.space-3; padding-left: Theme.space-3;
padding-bottom: Theme.space-2;
Text { Text {
text: @tr("Quick Actions"); text: @tr("Recent Messages");
font-size: Theme.font-body; font-size: Theme.font-body;
font-weight: Theme.weight-medium; font-weight: Theme.weight-medium;
color: Theme.text; color: Theme.text;
} }
} }
QuickNav { // Scrolls when the window is low, so it never makes the window taller.
icon: Icons.plus; if root.dms: dm-list := ScrollView {
text: @tr("Add a Server"); vertical-stretch: 1;
clicked => { Nav.add-server(); } VerticalLayout {
} width: dm-list.visible-width;
QuickNav { alignment: start;
icon: Icons.log-in; spacing: Theme.space-1;
text: @tr("Join a Server"); for chat in Bridge.sidebar-dms: ConversationRow {
clicked => { Nav.add-server(); } chat: chat;
} }
QuickNav {
icon: Icons.user-plus;
text: @tr("Find Friends");
clicked => {
Nav.friends-tab = 1;
Bridge.friends-tab(1);
Nav.show(Page.friends);
} }
} }
SidebarArt { if !root.dms: Rectangle {
vertical-stretch: 1; vertical-stretch: 1;
} }
} }
// An arrow over the live streams' row: a dark round button with a light
// A slide arrow of the banner: a dark round button with a light ring. // ring.
component BannerArrow inherits Rectangle { component BannerArrow inherits Rectangle {
in property <image> icon; in property <image> icon;
in property <string> label; in property <string> 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 { component HomeBanner inherits Rectangle {
in property <bool> compact; in property <bool> compact;
property <int> slide: 0;
property <int> count: Bridge.servers.length + 1;
property <ServerItem> server: Bridge.servers[max(0, root.slide - 1)];
min-height: compact ? 200px : 212px; min-height: compact ? 200px : 212px;
border-radius: Theme.radius-xl; border-radius: Theme.radius-xl;
clip: true; clip: true;
background: root.slide == 0 background: @linear-gradient(115deg, #0e1d5c 0%, #1c1470 45%, #3a1f86 75%, #0b2a6b 100%);
? @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%);
border-width: 1px; border-width: 1px;
border-color: Theme.border-strong; border-color: Theme.border-strong;
accessible-role: AccessibleRole.groupbox; 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 // 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 { Art {
source: Icons.art-banner; source: Icons.art-banner;
cover-width: parent.width; cover-width: parent.width;
cover-height: parent.height; cover-height: parent.height;
align-x: 1; align-x: 1;
} }
if root.slide > 0: Rectangle {
background: root.server.tint.with-alpha(0.28);
}
if root.compact: Rectangle { if root.compact: Rectangle {
background: @linear-gradient(90deg, #060c2cc0 0%, #060c2c50 55%, transparent 85%); 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. // 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; x: parent.width - 180px;
y: 24px; y: 24px;
width: 160px; width: 160px;
@@ -268,7 +158,7 @@ component HomeBanner inherits Rectangle {
padding-left: root.compact ? Theme.space-5 : 44px; padding-left: root.compact ? Theme.space-5 : 44px;
spacing: Theme.space-3; spacing: Theme.space-3;
alignment: center; alignment: center;
if root.slide == 0: HorizontalLayout { HorizontalLayout {
spacing: Theme.space-4; spacing: Theme.space-4;
alignment: start; alignment: start;
Image { Image {
@@ -284,93 +174,112 @@ component HomeBanner inherits Rectangle {
vertical-alignment: center; 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 {
text: root.slide == 0 ? @tr("Voice, chat and streams\non TeamSpeak servers.") text: @tr("Voice, chat and streams\non TeamSpeak servers.");
: root.server.flavor != "" ? root.server.flavor : @tr("Not reached yet");
color: #ffffff; color: #ffffff;
font-size: root.compact ? Theme.font-lg : Theme.font-2xl; font-size: root.compact ? Theme.font-lg : Theme.font-2xl;
font-weight: Theme.weight-medium; font-weight: Theme.weight-medium;
wrap: word-wrap; wrap: word-wrap;
} }
Text { 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; color: #c9d4ff;
wrap: word-wrap; wrap: word-wrap;
} }
HorizontalLayout { HorizontalLayout {
alignment: start; alignment: start;
spacing: Theme.space-3;
padding-top: Theme.space-2; padding-top: Theme.space-2;
if root.slide == 0: Button { Button {
kind: ButtonKind.primary; kind: ButtonKind.primary;
icon: Icons.arrow-right; icon: Icons.arrow-right;
text: @tr("Add a Server"); text: @tr("Add a Server");
clicked => { Nav.add-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 { // Where we were with voice last: the channel and its server, Join (Open
x: Theme.space-3; // while voice is there).
y: parent.height - self.height - 12px; component ResumeCard inherits Rectangle {
icon: Icons.chevron-left; in property <ResumeItem> place;
label: @tr("Previous"); in property <bool> compact;
clicked => { root.slide = mod(root.slide + root.count - 1, root.count); } 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 { // The server's colour, fading out to the right.
x: parent.width - self.width - Theme.space-3; Rectangle {
y: parent.height - self.height - 12px; background: @linear-gradient(90deg, root.place.tint.with-alpha(0.3) 0%, root.place.tint.with-alpha(0) 65%);
icon: Icons.chevron-right;
label: @tr("Next");
clicked => { root.slide = mod(root.slide + 1, root.count); }
} }
if root.count > 1: HorizontalLayout { HorizontalLayout {
y: parent.height - (root.compact ? 22px : 17px); padding: root.compact ? Theme.space-3 : Theme.space-4;
height: 10px; padding-left: root.compact ? Theme.space-3 : Theme.space-5;
alignment: center; spacing: root.compact ? Theme.space-3 : Theme.space-4;
spacing: Theme.space-3; VerticalLayout {
for i in root.count: Rectangle { alignment: center;
width: 8px; Avatar {
height: 8px; size: root.compact ? 44px : 52px;
border-radius: 4px; square: true;
background: i == root.slide ? #ffffff : #ffffff50; initials: root.place.initials;
TouchArea { image: root.place.icon;
mouse-cursor: MouseCursor.pointer; tint: root.place.tint;
clicked => { root.slide = i; } 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. // The main column of the home page.
export component HomePage inherits Rectangle { 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 <bool> compact; in property <bool> 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 <bool> first-run: Bridge.servers.length == 0 || Nav.first-run;
// Friends once: the bubbles where the right column with what friends
// do is hidden.
property <bool> bubbles: root.compact || !Nav.wide;
// The column inside its padding; a friend's bubble and the gap after it. // The column inside its padding; a friend's bubble and the gap after it.
property <length> row-width: sv.visible-width - 2 * Theme.space-4; property <length> row-width: sv.visible-width - 2 * Theme.space-4;
property <length> friend-gap: 6px; property <length> friend-gap: 6px;
@@ -905,10 +820,26 @@ export component HomePage inherits Rectangle {
padding: Theme.space-4; padding: Theme.space-4;
spacing: Theme.space-4; spacing: Theme.space-4;
alignment: start; alignment: start;
HomeBanner { if root.first-run: HomeBanner {
compact: root.compact; 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"); text: @tr("Friends Online");
icon: Icons.users; icon: Icons.users;
action: @tr("View All ({})", Bridge.friends-online.length); action: @tr("View All ({})", Bridge.friends-online.length);
@@ -918,13 +849,13 @@ export component HomePage inherits Rectangle {
Nav.show(Page.friends); 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."); 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; color: Theme.text-muted;
font-size: Theme.font-sm; font-size: Theme.font-sm;
wrap: word-wrap; wrap: word-wrap;
} }
if Bridge.friends-online.length > 0: HorizontalLayout { if root.bubbles && Bridge.friends-online.length > 0: HorizontalLayout {
spacing: root.friend-gap; spacing: root.friend-gap;
alignment: start; alignment: start;
// On the desktop as many whole bubbles as fit (the rest // On the desktop as many whole bubbles as fit (the rest
@@ -1090,78 +1021,6 @@ export component HomePage inherits Rectangle {
chat: chat; 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 <image> icon;
in property <string> title;
in property <string> 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 { } 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 { Section {
text: @tr("What's Happening"); text: @tr("What's Happening");
} }
+2 -2
View File
@@ -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 { 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"; import { MessageList, Composer } from "chat.slint";
// One conversation of the list. // One conversation of the list (also the home sidebar's).
component ConversationRow inherits Rectangle { export component ConversationRow inherits Rectangle {
in property <ConversationItem> chat; in property <ConversationItem> chat;
height: 64px * Theme.font-scale; height: 64px * Theme.font-scale;
border-radius: Theme.radius-md; border-radius: Theme.radius-md;
+2 -2
View File
@@ -7,8 +7,8 @@ import { Bridge, NoticeItem, SearchItem } from "../bridge.slint";
import { Nav, Page, SettingsSection } from "../nav.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"; import { Icon, Button, ButtonKind, IconButton, Avatar, Status, Chip, CountBadge, TextField, Kbd, Divider, ScrollView } from "../components/index.slint";
// One notification. // One notification (also home's unread mentions).
component NoticeRow inherits Rectangle { export component NoticeRow inherits Rectangle {
in property <NoticeItem> notice; in property <NoticeItem> notice;
// Never shorter than its text, so a long list scrolls instead of // Never shorter than its text, so a long list scrolls instead of
// squeezing the rows. // squeezing the rows.
+6 -5
View File
@@ -179,7 +179,7 @@ where a server has it.
| Part | `VOELIN_OPEN` | What it shows | Engine data | | 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 | | 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[:<uid>]` | 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` | | Friends | `friends[:<uid>]` | 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[:<uid>]`, `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`) | | Direct messages | `messages[:<uid>]`, `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 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 (`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 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 main button. Home's Add a Server opens this dialog too. The form also
form also carries a channel, its password and a privilege key for TeamSpeak carries a channel, its password and a privilege key for TeamSpeak links,
links, which are not stored with the server: with a channel the dialog shows which are not stored with the server: with a channel the dialog shows
"Joins <channel>" and Connect connects into it; with a key it shows "This "Joins <channel>" and Connect connects into it; with a key it shows "This
link grants a server group". 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`, `about`, `share[:live]`, `bookmark[:edit]`, `emoji`, `client`, `panel`, `no-panel`,
`voice`, `pins`, `topics`, `topic:<id>`, `member`, `poke`, `voice`, `pins`, `topics`, `topic:<id>`, `member`, `poke`,
`channel-password[:wrong]`, `actions` (the last message's actions, as if `channel-password[:wrong]`, `actions` (the last message's actions, as if
hovered: a screenshot cannot hover), `link-confirm[:<url>]` (the question hovered: a screenshot cannot hover), `first-run` (Home's banner as before
the first server, over the sample data), `link-confirm[:<url>]` (the question
before a masked link opens, by default the sample's), `unread` (the 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, 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, scrolled up to; `unread:end` ten messages before, at the end of the list,