ui: private chats on the Direct Messages page, not in the chat tabs

The server's chat strip shows the server chat and the channel chats.
Private chats stay tabs of their session, so history, the composer and
previews keep working, but the strip leaves them out (vm::chat::strip)
and a private chat is current only while the Direct Messages page shows
it; leaving the page goes back to the strip's last chat. The rail and the
Chats tab count only the server's and channels' unread messages; private
ones count on Direct Messages and, on the phone, on the Home tab.

Closing a tab left of the selected one no longer selects the next chat.
Voice connecting while a private chat is open keeps that conversation
(it became the voice channel's chat, and the composer sent there).

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-08 00:57:26 +00:00
1 parent 2e3ddc11ec
commit 48bc99a594
14 files changed
+414 -64

No files matched your search

+8
View File
@@ -98,6 +98,9 @@ User-visible changes of the apps and the `tsgw` gateway. The format follows
has it).
- The chat header's pinned messages and topics are icon buttons with a
count, so the channel's topic has room.
- Private chats live on the Direct Messages page, not in the server's chat
tabs, and their unread messages count there (on the phone, on the Home
tab) instead of on the server rail.
### Fixed
@@ -123,6 +126,11 @@ User-visible changes of the apps and the `tsgw` gateway. The format follows
line breaks.
- Joining a friend in a subchannel of a server without voice connects into
that subchannel; it connected into the default channel.
- Closing a chat tab left of the selected one keeps the selected chat; the
one after it was selected.
- Connecting with voice from a private chat (Direct Messages) keeps that
conversation open; it turned into the voice channel's chat, and the
composer sent there.
## [0.0.1-alpha] - 2026-10-04
+159 -3
View File
@@ -205,6 +205,11 @@ impl Tab {
}
}
/// A private chat (on the Direct Messages page, not in the chat strip).
pub fn is_private(&self) -> bool {
matches!(self.target, ChatTarget::Private(_))
}
/// A handle for a message that has none yet.
pub fn take_key(&mut self) -> i32 {
self.next_key += 1;
@@ -269,6 +274,10 @@ pub(crate) struct SessionView {
pub talking: HashSet<u16>,
pub tabs: Vec<Tab>,
pub current_tab: usize,
/// The chat strip's chat last current (the server's or a channel's): a
/// private chat is current only on the Direct Messages page, and this
/// one is current again when that page is left.
pub channel_tab: ChatTarget,
/// The own channel's tab was focused for this voice connection.
pub focused_own_channel: bool,
/// The streams in our channel (TeamSpeak 6).
@@ -325,6 +334,7 @@ impl Default for SessionView {
talking: HashSet::new(),
tabs: vec![Tab::new(ChatTarget::Server, "Server".into())],
current_tab: 0,
channel_tab: ChatTarget::Server,
focused_own_channel: false,
streams: Vec::new(),
applied_playback: HashSet::new(),
@@ -376,9 +386,62 @@ impl SessionView {
.map_or_else(|| format!("client {client}"), |c| c.nickname.clone())
}
/// Unread messages in all chats.
pub fn unread(&self) -> i32 {
self.tabs.iter().map(|t| t.unread).sum()
/// Unread messages in the server's and the channels' chats (the rail and
/// the chat strip count them; private chats count on the Direct
/// Messages page).
pub fn channel_unread(&self) -> i32 {
self.tabs.iter().filter(|t| !t.is_private()).map(|t| t.unread).sum()
}
/// Unread messages in private chats.
pub fn private_unread(&self) -> i32 {
self.tabs.iter().filter(|t| t.is_private()).map(|t| t.unread).sum()
}
/// Make tab `index` the current one; the chat strip remembers it unless
/// it is a private chat.
pub fn set_current_tab(&mut self, index: usize) {
self.current_tab = index;
if let Some(tab) = self.tabs.get(index).filter(|t| !t.is_private()) {
self.channel_tab = tab.target.clone();
}
}
/// Focus tab `index`. While a private chat is current (the Direct
/// Messages page shows it, and its composer sends there), a chat of the
/// strip does not take its place: it is the strip's chat, current once
/// that page is left (voice connecting focuses its channel's chat).
pub fn focus_tab(&mut self, index: usize) {
let Some(tab) = self.tabs.get(index) else { return };
if !tab.is_private() && self.tabs.get(self.current_tab).is_some_and(Tab::is_private) {
self.channel_tab = tab.target.clone();
} else {
self.set_current_tab(index);
}
}
/// Remove tab `index`. The current tab stays; when it is this one, the
/// chat strip's next tab takes its place, else its last.
pub fn remove_tab(&mut self, index: usize) -> Tab {
let tab = self.tabs.remove(index);
if self.current_tab > index {
self.current_tab -= 1;
} else if self.current_tab == index {
let (strip, _) = crate::vm::chat::strip(self.tabs.iter().map(|t| &t.target), 0);
let next = strip.iter().find(|&&i| i >= index).or(strip.last()).copied();
self.set_current_tab(next.unwrap_or(0));
}
tab
}
/// Leave a current private chat for the chat strip's last one (the
/// Direct Messages page was left); `true` if the current tab changed.
pub fn leave_private(&mut self) -> bool {
if !self.tabs.get(self.current_tab).is_some_and(Tab::is_private) {
return false;
}
self.current_tab = self.tabs.iter().position(|t| t.target == self.channel_tab).unwrap_or(0);
true
}
/// A new tab for `target`, read as far as the store says.
@@ -431,7 +494,10 @@ pub(crate) struct Models {
pub tree: Rc<VecModel<TreeItem>>,
pub members: Rc<VecModel<MemberItem>>,
pub server_members: Rc<VecModel<MemberItem>>,
/// The chat strip: the current session's tabs without its private chats.
pub tabs: Rc<VecModel<ChatTab>>,
/// Which of the session's tabs each of `tabs` is ([`crate::vm::chat::strip`]).
pub strip: RefCell<Vec<usize>>,
pub streams: Rc<VecModel<StreamItem>>,
pub viewers: Rc<VecModel<ViewerItem>>,
pub pins: Rc<VecModel<PinItem>>,
@@ -460,6 +526,7 @@ impl Models {
members: Rc::default(),
server_members: Rc::default(),
tabs: Rc::default(),
strip: RefCell::new(vec![0]),
streams: Rc::default(),
viewers: Rc::default(),
pins: Rc::default(),
@@ -1261,3 +1328,92 @@ impl App {
self.refresh_streams();
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn channel_unread_ignores_private_tabs() {
let mut view = SessionView::default();
view.tabs.push(Tab::new(ChatTarget::Channel(1), "Lobby".into()));
view.tabs.push(Tab::new(ChatTarget::Private("a".into()), "@Nova".into()));
for (tab, unread) in view.tabs.iter_mut().zip([1, 2, 4]) {
tab.unread = unread;
}
assert_eq!(view.channel_unread(), 3);
assert_eq!(view.private_unread(), 4);
}
/// Closing a tab keeps the current chat, or selects the strip's next
/// one (never a private chat).
#[test]
fn closing_a_tab_keeps_the_current_chat() {
let mut view = SessionView::default();
for target in [
ChatTarget::Channel(1),
ChatTarget::Channel(2),
ChatTarget::Private("a".into()),
ChatTarget::Channel(3),
] {
view.tabs.push(Tab::new(target, String::new()));
}
let current = |v: &SessionView| v.tabs[v.current_tab].target.clone();
view.set_current_tab(2);
view.remove_tab(1);
assert_eq!(current(&view), ChatTarget::Channel(2));
// [Server, 2, @a, 3]: the next tab of the strip, past the private chat.
view.remove_tab(1);
assert_eq!(current(&view), ChatTarget::Channel(3));
assert_eq!(view.channel_tab, ChatTarget::Channel(3));
// The last one: the strip's last, the server chat.
view.remove_tab(2);
assert_eq!(current(&view), ChatTarget::Server);
}
/// A private chat is current only on the Direct Messages page: leaving
/// it goes back to the strip's last chat.
#[test]
fn leaving_a_private_chat_restores_the_strip_tab() {
let mut view = SessionView::default();
view.tabs.push(Tab::new(ChatTarget::Channel(1), "Lobby".into()));
view.tabs.push(Tab::new(ChatTarget::Private("a".into()), "@Nova".into()));
view.set_current_tab(1);
assert!(!view.leave_private());
view.set_current_tab(2);
assert_eq!(view.channel_tab, ChatTarget::Channel(1));
assert!(view.leave_private());
assert_eq!(view.current_tab, 1);
// The strip's chat was closed meanwhile: the server chat.
view.set_current_tab(2);
view.tabs.remove(1);
view.current_tab = 1;
assert!(view.leave_private());
assert_eq!(view.current_tab, 0);
}
/// A channel's chat focused while a private chat is current (voice
/// connecting on the Direct Messages page) waits for the page to be
/// left: the conversation and its composer stay the private chat's.
#[test]
fn a_strip_chat_does_not_replace_a_current_private_chat() {
let mut view = SessionView::default();
view.tabs.push(Tab::new(ChatTarget::Channel(1), "Lobby".into()));
view.tabs.push(Tab::new(ChatTarget::Private("a".into()), "@Nova".into()));
view.tabs.push(Tab::new(ChatTarget::Private("b".into()), "@Ivy".into()));
view.focus_tab(2);
assert_eq!(view.current_tab, 2);
view.focus_tab(1);
assert_eq!((view.current_tab, &view.channel_tab), (2, &ChatTarget::Channel(1)));
// Another private chat does.
view.focus_tab(3);
assert_eq!(view.current_tab, 3);
assert!(view.leave_private());
assert_eq!(view.current_tab, 1);
// Without a private chat current, any chat.
view.focus_tab(0);
assert_eq!((view.current_tab, &view.channel_tab), (0, &ChatTarget::Server));
view.focus_tab(9);
assert_eq!(view.current_tab, 0);
}
}
+11 -2
View File
@@ -13,11 +13,20 @@ pub(super) fn wire(ui: &MainWindow) {
bridge.on_open_channel_chat(|cid| {
with_app(|app| app.open_chat(ChatTarget::Channel(cid as ChannelId), true));
});
// A tab of the chat strip, which leaves out private chats.
bridge.on_select_tab(|i| {
with_app(|app| app.select_tab(i as usize));
with_app(|app| {
if let Some(index) = app.strip_tab(i) {
app.select_tab(index);
}
});
});
bridge.on_close_tab(|i| {
with_app(|app| app.close_tab(i as usize));
with_app(|app| {
if let Some(index) = app.strip_tab(i) {
app.close_tab(index);
}
});
});
bridge.on_send_message(|text| {
with_app(|app| app.send_message(text.to_string()));
+10 -3
View File
@@ -3,7 +3,7 @@
use slint::ComponentHandle;
use crate::app::{Bridge, MainWindow, with_app};
use crate::app::{App, Bridge, MainWindow, with_app};
pub(super) fn wire(ui: &MainWindow) {
let bridge = ui.global::<Bridge>();
@@ -111,9 +111,16 @@ pub(super) fn wire(ui: &MainWindow) {
with_app(|app| app.open_preview(key, index)).unwrap_or_default()
});
// Opening the messages or the Library loads what they list.
// Opening the messages or the Library loads what they list; the open
// private chat is the current chat while the messages page shows it.
bridge.on_open_messages(|| {
with_app(|app| app.load_recent_chats());
with_app(|app| {
app.messages_shown();
app.load_recent_chats();
});
});
bridge.on_close_messages(|| {
with_app(App::close_messages);
});
bridge.on_open_library(|| {
with_app(|app| app.load_library());
+42 -25
View File
@@ -1,5 +1,7 @@
//! Chat: tabs per session (server, channels, private chats), their
//! messages, and what a gateway adds to them (pins, reactions, topics).
//! The chat strip shows the server's and the channels' tabs; a private chat
//! is the current tab only while the messages page shows it (messages.rs).
//!
//! The engine keeps the history: [`Event::ChatHistory`] is an upsert of
//! messages by their local id (see `voelin_core::history`), so a tab holds
@@ -103,25 +105,9 @@ fn ago(ts_ms: i64) -> String {
impl App {
pub(crate) fn open_chat(&mut self, target: ChatTarget, focus: bool) {
let Some(id) = self.current else { return };
let peer = match &target {
ChatTarget::Private(uid) => self.peer_name(uid, None),
_ => String::new(),
};
let view = self.sessions.entry(id).or_default();
let title = vm::chat::tab_title(&view.presence, &target, &peer);
let index = match view.tabs.iter().position(|t| t.target == target) {
Some(i) => i,
None => {
let tab = view.new_tab(target.clone(), title);
view.tabs.push(tab);
if !self.demo_ui {
self.engine.send(Command::OpenChat { session: id as u64, target });
}
view.tabs.len() - 1
}
};
let index = self.chat_tab(id, target);
if focus {
view.current_tab = index;
self.sessions.entry(id).or_default().focus_tab(index);
self.prefetch_counts();
self.track_reading();
}
@@ -129,11 +115,37 @@ impl App {
self.refresh_servers();
}
/// The index of `target`'s tab in session `id`, opened if new (the
/// engine then sends its history).
pub(crate) fn chat_tab(&mut self, id: i64, target: ChatTarget) -> usize {
let peer = match &target {
ChatTarget::Private(uid) => self.peer_name(uid, None),
_ => String::new(),
};
let view = self.sessions.entry(id).or_default();
if let Some(i) = view.tabs.iter().position(|t| t.target == target) {
return i;
}
let title = vm::chat::tab_title(&view.presence, &target, &peer);
let tab = view.new_tab(target.clone(), title);
view.tabs.push(tab);
if !self.demo_ui {
self.engine.send(Command::OpenChat { session: id as u64, target });
}
view.tabs.len() - 1
}
/// The session's tab that tab `index` of the chat strip is
/// (`Bridge.tabs`, [`vm::chat::strip`]).
pub(crate) fn strip_tab(&self, index: i32) -> Option<usize> {
self.models.strip.borrow().get(usize::try_from(index).ok()?).copied()
}
pub(crate) fn select_tab(&mut self, index: usize) {
if let Some(view) = self.view_mut()
&& index < view.tabs.len()
{
view.current_tab = index;
view.set_current_tab(index);
view.tabs[index].topic = None;
}
if let Some(id) = self.current {
@@ -152,9 +164,7 @@ impl App {
return;
}
self.save_read(id, index);
let view = self.sessions.entry(id).or_default();
let tab = view.tabs.remove(index);
view.current_tab = view.current_tab.min(view.tabs.len() - 1);
let tab = self.sessions.entry(id).or_default().remove_tab(index);
self.engine.send(Command::CloseChat { session: id as u64, target: tab.target });
self.prefetch_counts();
self.track_reading();
@@ -460,6 +470,9 @@ impl App {
&self.models.tabs,
&[ChatTab { title: "Server".into(), ..Default::default() }],
);
*self.models.strip.borrow_mut() = vec![0];
bridge.set_current_tab(0);
bridge.set_current_chat(0);
let empty = ModelRc::from(self.models.no_chat.clone());
if bridge.get_messages() != empty {
bridge.set_messages(empty);
@@ -467,9 +480,12 @@ impl App {
bridge.set_unread_index(-1);
return;
};
let tabs: Vec<ChatTab> = view
.tabs
// Private chats are on the messages page, not in the strip.
let (strip, current) =
vm::chat::strip(view.tabs.iter().map(|t| &t.target), view.current_tab);
let tabs: Vec<ChatTab> = strip
.iter()
.map(|&i| &view.tabs[i])
.map(|t| {
let (last, time) = t
.messages
@@ -508,10 +524,11 @@ impl App {
})
.collect();
vm::list::sync(&self.models.tabs, &tabs);
let current = view.current_tab as i32;
*self.models.strip.borrow_mut() = strip;
if bridge.get_current_tab() != current {
bridge.set_current_tab(current);
}
bridge.set_current_chat(view.current_tab as i32);
let tab = &view.tabs[view.current_tab];
// Sessions without stored history push their lines themselves.
let mut divider = None;
+2 -2
View File
@@ -4,7 +4,6 @@
use slint::ComponentHandle;
use voelin_core::{Command, Contact, Relation};
use voelin_model::ChatTarget;
use crate::app::{App, Bridge, MemberCard, Nav};
use crate::settings::ClientPlayback;
@@ -88,10 +87,11 @@ impl App {
};
let (client_id, nickname, uid) = (client.id, client.nickname.clone(), client.uid.clone());
match action {
// Private chats are on the messages page.
"message" => {
if let Some(uid) = uid {
self.open_chat(ChatTarget::Private(uid), true);
self.open_member(-1);
self.open_dm_with(Some(id), &uid);
}
}
"watch" => {
+78 -9
View File
@@ -6,8 +6,12 @@
//! 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
//! and its tab: the chat view's machinery (history pages, the composer)
//! serves it. A chat only in the store (its server is not connected, or no
//! longer a bookmark) is read from there and shown read-only.
//! serves it. The chat strip of the server page leaves these tabs out, so
//! leaving the messages page makes the strip's chat current again
//! ([`App::close_messages`]), and coming back the open one
//! ([`App::messages_shown`]). A chat only in the store (its server is not
//! connected, or no longer a bookmark) is read from there and shown
//! read-only.
use std::collections::HashMap;
@@ -16,7 +20,9 @@ use voelin_core::{Command, HistoryMessage, OfflineMessage, OfflineMessageInfo, V
use voelin_model::ChatTarget;
use voelin_store::PageQuery;
use crate::app::{App, Bridge, ConversationItem, DmPeer, FileItem, Nav, OfflineForm, Page, later};
use crate::app::{
App, Bridge, ConversationItem, DmPeer, FileItem, Nav, OfflineForm, Page, SessionView, later,
};
use crate::vm;
use crate::vm::social::{ago, list_time, matches, plain, preview};
@@ -305,11 +311,77 @@ impl App {
.collect()
};
vm::list::sync(&self.models.social.conversations, &items);
let unread: i32 = dm.chats.iter().filter(private).map(|c| c.unread).sum();
bridge.set_dm_unread(unread);
bridge.set_dm_unread(self.dm_unread());
bridge.set_inbox_unread(dm.inbox.iter().filter(|(_, m)| !m.read).count() as i32);
}
/// Unread messages in the private chats of every server (the rail and
/// the chat strip leave them out).
pub(crate) fn dm_unread(&self) -> i32 {
self.bookmarks
.iter()
.filter_map(|b| self.sessions.get(&b.id))
.map(SessionView::private_unread)
.sum()
}
/// The messages page is shown: the open private chat a session holds is
/// the current chat again (leaving the page made the strip's current).
pub(crate) fn messages_shown(&mut self) {
let Some(Open { session: Some(id), uid, mail: None, stored: false, .. }) =
self.social.dm.open.clone()
else {
return;
};
let target = ChatTarget::Private(uid);
// Not for a session that is gone (its server was deleted).
let Some(view) = self.sessions.get(&id) else { return };
if !view.tabs.iter().any(|t| t.target == target)
|| (self.current == Some(id)
&& view.tabs.get(view.current_tab).is_some_and(|t| t.target == target))
{
return;
}
self.focus_private(id, target);
}
/// Make the private chat `target` session `id`'s current chat, and that
/// server the current one. The tab first: selecting the server reads
/// the chat it shows, which must not be the strip's.
fn focus_private(&mut self, id: i64, target: ChatTarget) {
let index = self.chat_tab(id, target.clone());
self.sessions.entry(id).or_default().set_current_tab(index);
if self.current != Some(id) {
self.select_server(id);
}
self.open_chat(target, true);
}
/// The messages page was left: a session whose current chat is a
/// private one goes back to the chat strip's
/// ([`SessionView::channel_tab`]).
pub(crate) fn close_messages(&mut self) {
let mut changed = false;
for view in self.sessions.values_mut() {
changed |= view.leave_private();
}
if !changed {
return;
}
self.refresh_chat();
self.refresh_servers();
// What is read after the callback: a server picked on the rail
// (`Nav.select-server` leaves the page first) is selected by then,
// and the chat that came back here was never on screen.
later(|app| {
if let Some(id) = app.current {
app.fetch_previews(id);
}
app.prefetch_counts();
app.chat_shown_changed();
});
}
pub(crate) fn dm_tab(&mut self, tab: i32) {
self.social.dm.tab = tab;
if tab == 2 {
@@ -397,10 +469,7 @@ impl App {
vm::list::sync(&self.models.social.dm_lines, &[]);
let target = ChatTarget::Private(uid.to_owned());
if let (true, Some(id)) = (live, session) {
if self.current != Some(id) {
self.select_server(id);
}
self.open_chat(target, true);
self.focus_private(id, target);
} else if let Some(server_uid) = server_uid.filter(|_| !self.demo_ui) {
let history = self.engine.history();
let uid = uid.to_owned();
+7 -3
View File
@@ -383,7 +383,9 @@ impl App {
self.bookmarks.iter().position(|b| b.id == id).map(|i| tints[i]).unwrap_or_default()
}
/// The rail: servers with their state, unread count and streams.
/// The rail: servers with their state, unread count (without private
/// chats) and streams; what the chat strip and the private chats have
/// unread.
pub(crate) fn refresh_servers(&self) {
let Some(ui) = self.ui.upgrade() else { return };
let bridge = ui.global::<Bridge>();
@@ -395,7 +397,7 @@ impl App {
.map(|(b, tint)| {
let view = self.sessions.get(&b.id);
let state = view.map(|v| v.state.clone()).unwrap_or_default();
let unread = view.map_or(0, |v| v.unread());
let unread = view.map_or(0, SessionView::channel_unread);
let live = view.is_some_and(|v| v.streams_available() && !v.streams.is_empty());
let detail = view
.filter(|v| !v.presence.channels.is_empty())
@@ -409,7 +411,9 @@ impl App {
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()));
// Private chats count on the messages page (and the phone's Home).
bridge.set_unread_total(self.view().map_or(0, SessionView::channel_unread));
bridge.set_dm_unread(self.dm_unread());
}
/// The server card, the voice controls and who we are.
+57
View File
@@ -424,6 +424,25 @@ pub fn tab_title(presence: &Presence, target: &ChatTarget, peer: &str) -> String
}
}
/// The chat strip of a session's tabs (by their chats, in order): which
/// tabs it shows, by their index among all, and which of those is the
/// current one (-1 when the current tab is not shown). The server chat and
/// the channels' chats are shown; a private chat is on the Direct Messages
/// page.
pub fn strip<'a>(
targets: impl IntoIterator<Item = &'a ChatTarget>,
current: usize,
) -> (Vec<usize>, i32) {
let shown: Vec<usize> = targets
.into_iter()
.enumerate()
.filter(|(_, t)| !matches!(t, ChatTarget::Private(_)))
.map(|(i, _)| i)
.collect();
let selected = shown.iter().position(|&i| i == current).map_or(-1, |i| i as i32);
(shown, selected)
}
/// A chat tab's name for its header: the title without a private chat's
/// "@" (a channel may start with one).
pub fn tab_name<'a>(title: &'a str, target: &ChatTarget) -> &'a str {
@@ -843,6 +862,44 @@ mod tests {
assert_eq!(tab_name("@home", &ChatTarget::Channel(4)), "@home");
}
fn targets() -> Vec<ChatTarget> {
vec![
ChatTarget::Server,
ChatTarget::Private("a".into()),
ChatTarget::Channel(1),
ChatTarget::Private("b".into()),
ChatTarget::Channel(2),
]
}
/// Private chats are on the Direct Messages page, not in the strip.
#[test]
fn strip_hides_private() {
let targets = targets();
assert_eq!(strip(&targets, 2), (vec![0, 2, 4], 1));
assert_eq!(strip(&targets, 4), (vec![0, 2, 4], 2));
assert_eq!(strip(&[], 0), (vec![], -1));
}
#[test]
fn strip_current_private_is_minus_one() {
let targets = targets();
assert_eq!(strip(&targets, 1).1, -1);
assert_eq!(strip(&targets, 3).1, -1);
// A current tab that is gone selects nothing either.
assert_eq!(strip(&targets, 9).1, -1);
}
/// The server chat is the strip's first tab, before private chats too.
#[test]
fn strip_server_tab_first() {
let targets = targets();
let (shown, selected) = strip(&targets, 0);
assert_eq!((shown[0], selected), (0, 0));
let only = [ChatTarget::Server, ChatTarget::Private("a".into())];
assert_eq!(strip(&only, 0), (vec![0], 0));
}
/// The header counts pins and topics only once the gateway sent them.
#[test]
fn counts_are_unknown_until_loaded() {
+11 -2
View File
@@ -889,8 +889,13 @@ export global Bridge {
in property <[MemberItem]> server-members;
// How many people are on the server (not counting query clients).
in property <int> member-total;
// The chat strip: the server's chat and the channels' (private chats
// are on the messages page), and its current tab (-1 while the current
// chat is a private one).
in property <[ChatTab]> tabs;
in-out property <int> current-tab: 0;
// Which of the session's chats is current (also a private one).
in property <int> current-chat;
in property <[ChatLine]> messages;
// Older messages can still be loaded in the current chat.
in property <bool> more-history;
@@ -927,7 +932,8 @@ export global Bridge {
in property <int> unread-count;
in property <string> unread-since;
in property <string> status-text;
// Unread messages in all chats of the current server.
// Unread messages in the current server's chat and channel chats (its
// private chats count in `dm-unread`).
in property <int> unread-total;
in property <string> server-title: @tr("No server selected");
// "12 online · 8 channels"
@@ -1052,6 +1058,7 @@ export global Bridge {
callback join-with-password(string);
callback open-channel-chat(int);
callback toggle-collapse(int);
// A tab of `tabs` (the chat strip) by its place there.
callback select-tab(int);
callback close-tab(int);
callback send-message(string);
@@ -1167,8 +1174,10 @@ export global Bridge {
in property <[RecordingItem]> recordings;
in property <string> recordings-dir;
callback open-conversation(int);
// The messages page and the Library were opened.
// The messages page and the Library were opened; the messages page was
// left (a private chat stops being the current chat).
callback open-messages();
callback close-messages();
callback open-library();
callback watch-live(int, string);
callback open-happening(int);
+10 -1
View File
@@ -138,8 +138,10 @@ export global Nav {
out property <bool> chat-shown: (page == Page.server && (!narrow || phone-voice || mobile-tab == MobileTab.chat))
|| (page == Page.messages && Bridge.dm.open && !Bridge.dm.mail && !Bridge.dm.stored);
// Settings were opened (so leaving them tells Rust).
// Settings, or the messages page, were opened (so leaving them tells
// Rust).
property <bool> settings-active;
property <bool> messages-active;
public function show(p: Page) {
if p != Page.settings && settings-active {
@@ -157,10 +159,17 @@ export global Nav {
}
page = p;
notifications-open = false;
// After the page changed: the chat Rust goes back to is read only
// where the new page shows it.
if p != Page.messages && messages-active {
messages-active = false;
Bridge.close-messages();
}
if p == Page.events {
Bridge.open-events();
}
if p == Page.messages {
messages-active = true;
Bridge.open-messages();
}
if p == Page.library {
+7 -5
View File
@@ -653,8 +653,9 @@ export component MessageList inherits VerticalLayout {
root.kept-rows = -1;
}
}
// Another chat (another tab, or another server's tab at the same
// place): start at its end, with nothing of the last one's loading.
// Another chat (another tab or private chat, or another server's chat
// at the same place): start at its end, with nothing of the last one's
// loading.
function reset() {
root.follow = true;
root.kept-rows = -1;
@@ -662,8 +663,8 @@ export component MessageList inherits VerticalLayout {
root.paused = false;
list.content-y = root.end;
}
property <int> tab: Bridge.current-tab;
changed tab => { root.reset(); }
property <int> chat: Bridge.current-chat;
changed chat => { root.reset(); }
property <int> server: Bridge.current-server;
changed server => { root.reset(); }
// Scroll to where row `index` is, a third down the view. Rows differ in
@@ -907,7 +908,8 @@ export component ChatView inherits VerticalLayout {
}
}
}
// Chat tabs: server chat, channel chats, private chats.
// Chat tabs: the server chat and channel chats (private chats are on
// the messages page).
Rectangle {
height: Theme.control-height + 4px;
accessible-role: AccessibleRole.tab-list;
+3 -1
View File
@@ -107,7 +107,7 @@ export component MobileShell inherits Rectangle {
in property <string> title;
in property <string> subtitle;
in property <image> banner;
// Total unread messages (the Chat tab's badge).
// Unread messages in the server's chats (the Chat tab's badge).
in property <int> unread;
// Show a back arrow (sub-pages such as the settings).
in property <bool> back;
@@ -264,10 +264,12 @@ export component MobileShell inherits Rectangle {
HorizontalLayout {
padding-left: Theme.space-2;
padding-right: Theme.space-2;
// The direct messages are on Home: their unread count.
NavTab {
icon: Icons.home;
text: @tr("Home");
selected: Nav.page == Page.home || Nav.page == Page.friends || Nav.page == Page.messages || Nav.page == Page.library || (Nav.mobile-tab == MobileTab.home && Nav.page == Page.server);
badge: Bridge.dm-unread + Bridge.inbox-unread;
clicked => { Nav.show-tab(MobileTab.home); }
}
NavTab {
+9 -8
View File
@@ -153,9 +153,9 @@ comes from the engine's events; what a gateway adds is hidden without it.
| Part | `VOELIN_OPEN` | What it shows | Engine data |
|---|---|---|---|
| Chat | `server` (`server:chat`: the server chat), `actions`, `link-confirm[:<url>]`, `unread[:end]` | Header with the channel's topic, then icon buttons for Pinned messages and Topics (each with its count once the gateway sent them: asked for when the chat is shown), the voice channel and the members; chat tabs; messages grouped by author ("Today at 10:14"), avatars, BBCode formatting (see Formatting below), emoji, reactions with an add button, pin and topic marks, file cards with download; composer with attach, emoji and send. A link opens in the browser; one whose text is not its address (a masked link) first shows where it goes in `LinkDialog` (the host, the whole address; Open, Copy link, Cancel); a TeamSpeak link opens in Voelin (Adding a server: Links, below); a right-click on a link offers Open link and Copy link. Every message has actions on hover (`MessageActions`; `actions` shows the last one's): Quote (`> Author: …` lines at the start of the composer, which takes the focus to write below them and grows to show up to about eight lines) and Copy text, and with a gateway quick reactions, pin and Start a topic; a right-click on a message shows Copy text, Copy link (its first web address), Quote, and with a gateway React… and Pin. The server chat starts with the server's welcome message (and its host message when the server puts it in the chat log). Opens at the newest message and follows new ones while at the end. Scrolling up to within a screen of the top loads the page before, above the rows on screen, which stay in place (a spinner above the oldest message while it loads). The Older messages button there is for a chat too short to scroll, and for after a page that brought nothing (scrolling loads again once the list was a screen away). The voice view, the phone's voice screen and private chats load the same way. Messages count as read while their chat is on screen in the focused window; the chat tabs and the server rail count the others (not our own). A chat that comes on screen with new messages, or that is on screen when messages that came while away arrive (a stored or gateway page), shows a red line with New above the first (`NewDivider`) until the chat is left; while that line is above the view, a bar over the list says how many are new and since when (`UnreadBar`: "5 new messages since 10:14", Jump, and × to mark them read). Where each chat was read is kept on this device (the store's `chat_reads`), so the counts survive a restart: messages that came while away (a gateway's history) count as new | `ChatHistory` (and `Chat` for servers without history), `Presence` (welcome and host message), `AvatarReady`, `Transfer`, `Gateway` (pins; reactions arrive as stored messages); `Command::LoadOlderHistory`, `DownloadChatFile`, `UploadFile`, `GatewayRequest::React`, `Unreact`, `Pin`, `Unpin` |
| Chat | `server` (`server:chat`: the server chat), `actions`, `link-confirm[:<url>]`, `unread[:end]` | Header with the channel's topic, then icon buttons for Pinned messages and Topics (each with its count once the gateway sent them: asked for when the chat is shown), the voice channel and the members; chat tabs (the server chat and channel chats; private chats are on the Direct Messages page); messages grouped by author ("Today at 10:14"), avatars, BBCode formatting (see Formatting below), emoji, reactions with an add button, pin and topic marks, file cards with download; composer with attach, emoji and send. A link opens in the browser; one whose text is not its address (a masked link) first shows where it goes in `LinkDialog` (the host, the whole address; Open, Copy link, Cancel); a TeamSpeak link opens in Voelin (Adding a server: Links, below); a right-click on a link offers Open link and Copy link. Every message has actions on hover (`MessageActions`; `actions` shows the last one's): Quote (`> Author: …` lines at the start of the composer, which takes the focus to write below them and grows to show up to about eight lines) and Copy text, and with a gateway quick reactions, pin and Start a topic; a right-click on a message shows Copy text, Copy link (its first web address), Quote, and with a gateway React… and Pin. The server chat starts with the server's welcome message (and its host message when the server puts it in the chat log). Opens at the newest message and follows new ones while at the end. Scrolling up to within a screen of the top loads the page before, above the rows on screen, which stay in place (a spinner above the oldest message while it loads). The Older messages button there is for a chat too short to scroll, and for after a page that brought nothing (scrolling loads again once the list was a screen away). The voice view, the phone's voice screen and private chats load the same way. Messages count as read while their chat is on screen in the focused window; the chat tabs and the server rail count the others (not our own; private chats count on Direct Messages). A chat that comes on screen with new messages, or that is on screen when messages that came while away arrive (a stored or gateway page), shows a red line with New above the first (`NewDivider`) until the chat is left; while that line is above the view, a bar over the list says how many are new and since when (`UnreadBar`: "5 new messages since 10:14", Jump, and × to mark them read). Where each chat was read is kept on this device (the store's `chat_reads`), so the counts survive a restart: messages that came while away (a gateway's history) count as new | `ChatHistory` (and `Chat` for servers without history), `Presence` (welcome and host message), `AvatarReady`, `Transfer`, `Gateway` (pins; reactions arrive as stored messages); `Command::LoadOlderHistory`, `DownloadChatFile`, `UploadFile`, `GatewayRequest::React`, `Unreact`, `Pin`, `Unpin` |
| Members panel | `server` (`panel`, `no-panel`) | "Members — N" and a search; those streaming first (the people in our channel while the voice channel or a stream is shown), then each server group in the server's order with its icon, then those without a group. Rows: avatar with status, name, crown (admin groups), priority speaker, channel commander, recording, up to three myTeamSpeak badges, moderator role, a hand when their channel needs more talk power than they have ("Needs talk power to speak"; the member card has the number), what they do or the channel they are in. Resizable: the width is `ui.members_width` | `Presence`, `Groups`, `Talking`, `IconReady`, `PictureReady` |
| Member card | `member` | Description, groups, badges (up to three chips in the client's order, what each is for on hover; "Badge" for one the app does not know), talk power, country; private message, poke, friend, block; volume and mute for us | `ContactsChanged`, `PictureReady` (badges); `Command::SetContact`, `SetClientVolume`, `SetClientMuted`, `Poke` |
| Member card | `member` | Description, groups, badges (up to three chips in the client's order, what each is for on hover; "Badge" for one the app does not know), talk power, country; private message (on Direct Messages), poke, friend, block; volume and mute for us | `ContactsChanged`, `PictureReady` (badges); `Command::SetContact`, `SetClientVolume`, `SetClientMuted`, `Poke` |
| Poke | `poke` (the first other member's, card open; after `friends` a contact's) | `PokeDialog`, from the member card, a friend's row and the direct message header: an optional message with a "12/100" count, Send off above 100 characters, Enter sends, Escape cancels | `Command::Poke` (trimmed, cut to 100 characters; the engine cuts too) |
| Channel password | `channel-password`, `channel-password:wrong` | Joining a channel (a double-click in the tree, joining a friend) moves there with voice, or connects into it (by its id) without; when the server puts us elsewhere on connecting, as it does for a wrong password, it is joined again, which says why. A locked channel first asks for its password in `ChannelPasswordDialog`, unless one was given since voice connected; a refused one asks again under "Wrong password". A full channel or another refusal is a toast | `Presence` (`has_password`), `JoinFailed`; `Command::MoveToChannel`, `ConnectVoice` (`channel_password`) |
| Pinned messages | `pins` | In the members panel's place: cards with author, time, text, files and reactions; the pin unpins, a click jumps to the message | `Gateway` `Pins`, `Pinned`, `Unpinned`; `GatewayRequest::Pins`, `Unpin` |
@@ -166,7 +166,8 @@ comes from the engine's events; what a gateway adds is hidden without it.
The pins and topics share the place of the members panel: opening one
closes the other, and the members button brings the panel back. On the
phone the chat is the Chat tab and the members of our channel are on the
Activity tab.
Activity tab. The Chat tab counts the server's unread chats; private chats
count on the Home tab, where the direct messages are.
## Home, friends, messages and the settings pages
@@ -184,7 +185,7 @@ where a server has it.
| 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[:<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. A private chat is not a tab of the server page: while it is open here it is its server's current chat (a channel's chat opened meanwhile, as voice connecting opens its channel's, waits), and leaving the page goes back to the server's last chat tab (coming back reopens it). Its unread messages count on Direct Messages (on the phone, on the Home tab), not on the server rail | `ChatHistory` (`ChatTarget::Private` by unique id), `Command::LoadOlderHistory`, `Poke`, offline messages (`ListOfflineMessages`, `GetOfflineMessage`, `SendOfflineMessage`, `DeleteOfflineMessage`, `SetOfflineMessageRead`) |
| The bell | `notifications` | A panel under the bell, as tall as its notices (up to 560 px, then it scrolls): mentions, pokes, private messages, event reminders and friends coming online, newest first, unread marked; Mark all read, clear, the settings. Each kind is off, in the app or also a desktop notification (`notify.*`) | `Chat` and `ChatHistory` (mentions, private messages), `Poke`, `GatewayUpdate::EventReminder`, `FriendPresence`; `voelin_platform::notify` |
| Search | `search[:<text>]` | Ctrl+K: servers, channels of every server, people (on the servers and the contacts) and the settings pages; arrows choose, Enter opens | the sessions, contacts, bookmarks |
| Events | `events`, `event-form` | Above the channel tree (gateway `events`): a server's events with date, time, channel, scheduled stream, Going, Maybe and Not going with counts, who answered, reminders, Watch while live; create, edit and delete. Members (above the tree too) opens the members panel | `Gateway` events; `GatewayRequest::Events`, `CreateEvent`, `UpdateEvent`, `DeleteEvent`, `Rsvp` |
@@ -583,10 +584,10 @@ pictures retain the normal background.
A channel has one icon everywhere, a speaker (`Icons.channel`, a lock for a
locked one in the tree), and chat tabs, notifications and search results name
it without a `#` (private chats keep their `@`). A server icon at most half
as wide as its avatar (TeamSpeak's are often 16 pixels) is drawn at twice its
size, sharp, on the server's colour instead of stretched. Avatars under 28
pixels, as the tree's clients, show one letter.
it without a `#`. A server icon at most half as wide as its avatar (TeamSpeak's
are often 16 pixels) is drawn at twice its size, sharp, on the server's colour
instead of stretched. Avatars under 28 pixels, as the tree's clients, show one
letter.
Bookmarks remember the server icon ID and the address that supplied it. The
server list, search results and server header load its cached bytes before