social/logic.rs now has the contacts as rows (contact_item, people), the buttons of a contact and what they ask the window to do next, the bell (notify, the rows, read, clear, open), the search with what each result opens, and what an engine event does to the friends, the pokes, the offline messages and the notices (event). events::handle runs that first, then events::apply, so a front end has one entry point; Social<D> is the state those keep, with what the messages page keeps as D for now. Refresh got people, conversations and dm, the host got dm_shown and now_ms, and Persist.Settings pages are told apart from the new notices. The Slint side (social/bind.rs) writes the Bridge, shows the desktop toasts and navigates. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
81 lines
3.0 KiB
Rust
81 lines
3.0 KiB
Rust
//! People across servers: contacts and where they are (Friends, home), the
|
|
//! bell's notifications, pokes, and the search (Ctrl+K). The direct
|
|
//! messages are in `messages.rs`, the home page in `home.rs`, a server's
|
|
//! events in `events.rs`.
|
|
//!
|
|
//! Every contact's whereabouts come from the sessions' presence (voice,
|
|
//! gateway or query), so they are current for friends and the others alike;
|
|
//! [`voelin_core::Event::FriendPresence`] adds when a friend came online, for
|
|
//! "12m ago" and the notification. What the screens show and what an event
|
|
//! or a move does to them is in `voelin_ui_vm::social::logic`; `bind` has
|
|
//! the Bridge writes, the desktop toasts and the navigation.
|
|
|
|
mod bind;
|
|
|
|
use crate::app::Bridge;
|
|
use crate::bind::rows::Rows;
|
|
use crate::vm;
|
|
|
|
pub(crate) use vm::social::{NoticeKind, NoticeTarget, now_ms};
|
|
|
|
/// State of the home, friends, messages, bell and search screens: the
|
|
/// view model's, with what the messages page keeps.
|
|
pub(crate) type Social = vm::social::logic::Social<crate::messages::Dms>;
|
|
|
|
/// The models of these screens, set on the Bridge once.
|
|
pub(crate) struct SocialModels {
|
|
pub friends_online: Rows<vm::bridge::ContactItem>,
|
|
pub friend_activity: Rows<vm::bridge::ContactItem>,
|
|
pub contacts: Rows<vm::bridge::ContactItem>,
|
|
pub blocked: Rows<vm::bridge::ContactItem>,
|
|
pub live: Rows<vm::bridge::LiveItem>,
|
|
pub recent: Rows<vm::bridge::ConversationItem>,
|
|
pub sidebar_dms: Rows<vm::bridge::ConversationItem>,
|
|
pub conversations: Rows<vm::bridge::ConversationItem>,
|
|
pub dm_lines: Rows<vm::bridge::ChatLine>,
|
|
pub happenings: Rows<vm::bridge::HappeningItem>,
|
|
pub recordings: Rows<vm::bridge::RecordingItem>,
|
|
pub notices: Rows<vm::bridge::NoticeItem>,
|
|
pub mentions: Rows<vm::bridge::NoticeItem>,
|
|
pub search: Rows<vm::bridge::SearchItem>,
|
|
pub events: Rows<vm::bridge::EventItem>,
|
|
}
|
|
|
|
impl SocialModels {
|
|
pub fn new(bridge: &Bridge) -> Self {
|
|
let m = Self {
|
|
friends_online: Rows::default(),
|
|
friend_activity: Rows::default(),
|
|
contacts: Rows::default(),
|
|
blocked: Rows::default(),
|
|
live: Rows::default(),
|
|
recent: Rows::default(),
|
|
sidebar_dms: Rows::default(),
|
|
conversations: Rows::default(),
|
|
dm_lines: Rows::default(),
|
|
happenings: Rows::default(),
|
|
recordings: Rows::default(),
|
|
notices: Rows::default(),
|
|
mentions: Rows::default(),
|
|
search: Rows::default(),
|
|
events: Rows::default(),
|
|
};
|
|
bridge.set_friends_online(m.friends_online.model());
|
|
bridge.set_friend_activity(m.friend_activity.model());
|
|
bridge.set_contacts(m.contacts.model());
|
|
bridge.set_blocked(m.blocked.model());
|
|
bridge.set_live_rooms(m.live.model());
|
|
bridge.set_recent_chats(m.recent.model());
|
|
bridge.set_sidebar_dms(m.sidebar_dms.model());
|
|
bridge.set_conversations(m.conversations.model());
|
|
bridge.set_dm_messages(m.dm_lines.model());
|
|
bridge.set_happenings(m.happenings.model());
|
|
bridge.set_recordings(m.recordings.model());
|
|
bridge.set_notifications(m.notices.model());
|
|
bridge.set_home_mentions(m.mentions.model());
|
|
bridge.set_search_results(m.search.model());
|
|
bridge.set_events(m.events.model());
|
|
m
|
|
}
|
|
}
|