Lightweight native Discord client for Windows, Linux and macOS, written in Rust. No Electron, no browser engine.
Rust desktop-appdiscorddiscord-clienteguielectron-alternativelightweightlinuxmacosnative-apprustwindows
RustCord 0.4.38: friend nicknames, channel menu, folder dragging
VRonGitHub9f2532897aba
diff --git a/Cargo.lock b/Cargo.lockindex 747914d..6b35405 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -1572,7 +1572,7 @@ dependencies = [[[package]]name = "discord"-version = "0.4.37"+version = "0.4.38"dependencies = ["anyhow","base64 0.22.1",@@ -5309,7 +5309,7 @@ checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4"[[package]]name = "rencord"-version = "0.4.37"+version = "0.4.38"dependencies = ["discord","log",@@ -5488,7 +5488,7 @@ dependencies = [[[package]]name = "rustcord"-version = "0.4.37"+version = "0.4.38"dependencies = ["arboard","base64 0.22.1",@@ -5528,7 +5528,7 @@ dependencies = [[[package]]name = "rustcord-setup"-version = "0.4.37"+version = "0.4.38"dependencies = ["embed-resource","flate2",diff --git a/Cargo.toml b/Cargo.tomlindex bd0e481..0effd4b 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -3,7 +3,7 @@ resolver = "2"members = ["crates/discord", "crates/rencord", "crates/voice", "apps/rustcord", "apps/setup"][workspace.package]-version = "0.4.37"+version = "0.4.38"edition = "2021"license = "PolyForm-Noncommercial-1.0.0"diff --git a/apps/rustcord/src/app.rs b/apps/rustcord/src/app.rsindex 14a0ad6..30b710f 100644--- a/apps/rustcord/src/app.rs+++ b/apps/rustcord/src/app.rs@@ -121,6 +121,13 @@ pub struct Toast {pub at: Instant,}+/// What is being dragged on the server rail.+#[derive(Clone, Copy, PartialEq, Debug)]+pub enum RailDrag {+ Server(Id),+ Folder(u64),+}+pub struct RustCord {pub ctx: egui::Context,pub backend: Backend,@@ -200,8 +207,8 @@ pub struct RustCord {pub compose: crate::features::ComposeTools,/// Channel or category being dragged in the channel list.pub channel_drag: Option<Id>,- /// Server being dragged on the server rail.- pub guild_drag: Option<Id>,+ /// Server or folder being dragged on the server rail.+ pub rail_drag: Option<RailDrag>,/// Server pages from the channel list header (Members, Server Boosts,/// Server Shop) and the Events popup.pub guild_pages: crate::ui::guild_pages::GuildPages,@@ -272,6 +279,8 @@ pub struct RustCord {/// Discord's "Accept friend request?" about this person (a stranger's/// request: no mutual friends or small servers), while it is up.pub stranger_confirm: Option<Id>,+ /// The "Add / Change Friend Nickname" dialog, while it is up.+ pub friend_nickname: Option<crate::ui::friend_nickname::FriendNickname>,/// People with a friend-list change queued or on its way (see/// `backend::relationship_queue`): their buttons wait.pub relationship_busy: std::collections::HashSet<Id>,@@ -338,6 +347,8 @@ pub struct RustCord {pub moderation: crate::ui::moderation::ModState,/// The server icon's right-click menu: server, where, frame it opened.pub guild_menu: Option<(Id, egui::Pos2, u64)>,+ /// A server channel's right-click menu: (channel, where, frame opened).+ pub channel_menu: Option<(Id, egui::Pos2, u64)>,/// A dialog opened from a server menu (Notification Settings, Privacy…).pub guild_dialog: Option<crate::ui::guild_menu::GuildDialog>,/// A dialog from the server menu / channel gear.@@ -580,7 +591,7 @@ impl RustCord {full_profile: None,compose: Default::default(),channel_drag: None,- guild_drag: None,+ rail_drag: None,guild_pages: Default::default(),pending_dm: None,audio: Default::default(),@@ -617,6 +628,7 @@ impl RustCord {pins_opened: 0,pin_confirm: None,stranger_confirm: None,+ friend_nickname: None,relationship_busy: Default::default(),dev_wave: None,threads_popout: None,@@ -651,6 +663,7 @@ impl RustCord {server_menu: None,moderation: Default::default(),guild_menu: None,+ channel_menu: None,guild_dialog: None,server_dialog: None,add_server: None,@@ -1663,7 +1676,7 @@ impl RustCord {// (Someone accepting your friend request: its text is your own note,// so the alert says what happened instead.)let text = if msg.kind == 67 { "Accepted your friend request.".to_string() } else { msg.content.clone() };- let alert = (pings && !ephemeral).then(|| (msg.guild_id, msg.author.display_name().to_string(), text));+ let alert = (pings && !ephemeral).then(|| (msg.guild_id, self.store.nick_in(None, Some(channel), author).unwrap_or_else(|| msg.display_name().to_string()), text));if let Some(c) = self.store.channels.get_mut(&channel).filter(|_| !ephemeral) {c.last_message_id = Some(msg.id);}@@ -2040,6 +2053,16 @@ impl RustCord {}return;}+ // `friend-nickname:<part of a username>`: "Add / Change Friend Nickname"+ // for that friend (use it with --demo: Save goes to the account).+ if let Some(name) = dev.strip_prefix("friend-nickname:") {+ let name = name.to_lowercase();+ let friend = self.store.relationships.values().filter(|r| r.kind == 1).map(|r| r.id).find(|id| self.store.users.get(id).is_some_and(|u| u.username.to_lowercase().contains(&name)));+ if let Some(id) = friend {+ self.open_friend_nickname(id);+ }+ return;+ }match dev.as_str() {// "Accept friend request?" about yourself; Accept sends nothing."stranger-confirm" => {@@ -2799,7 +2822,8 @@ impl RustCord {let Some(m) = self.store.message(channel, msg) else { return };// Like Discord: replies ping the author, except when it's yourself.let mine = Some(m.author.id) == self.store.me_id();- self.reply = Some(ReplyTarget { channel, msg, author: m.display_name().to_string(), mention: !mine });+ let author = self.store.nick_in(None, Some(channel), m.author.id).unwrap_or_else(|| m.display_name().to_string());+ self.reply = Some(ReplyTarget { channel, msg, author, mention: !mine });self.ctx.memory_mut(|mem| mem.request_focus(egui::Id::new(("composer", channel.0))));}@@ -3021,7 +3045,7 @@ impl RustCord {match (id_len > 0, tail[skip + id_len..].starts_with('>')) {(true, true) => {let id = tail[skip..skip + id_len].parse().ok().map(Id);- let name = id.and_then(|id| self.store.users.get(&id)).map(|u| u.display_name().to_string());+ let name = id.and_then(|id| self.store.users.get(&id)).map(|u| self.store.name_in(guild, Some(channel), u));body.push('@');body.push_str(name.as_deref().unwrap_or(if skip > 0 && tail.starts_with('&') { "role" } else { "user" }));rest = &tail[skip + id_len + 1..];diff --git a/apps/rustcord/src/demo.rs b/apps/rustcord/src/demo.rsindex 4dbb01a..9a3c09e 100644--- a/apps/rustcord/src/demo.rs+++ b/apps/rustcord/src/demo.rs@@ -1049,6 +1049,15 @@ pub async fn run(mut rx: UnboundedReceiver<Command>, em: Emitter) {Command::Api { tag, path, .. } if path.contains("/reactions/") => {em.emit(Event::Api { tag, result: Ok(json!([user(FERRIS), user(CLIPPY), user(CORRO)])) });}+ // A friend nickname: saved, and echoed back the way Discord's gateway does.+ Command::Api { tag, path, body, .. } if path.starts_with("/users/@me/relationships/") && body.as_ref().is_some_and(|b| b.get("nickname").is_some()) => {+ let id = path.rsplit('/').next().unwrap_or_default().to_string();+ let nickname = body.map(|b| b["nickname"].clone()).unwrap_or(Value::Null);+ em.emit(Event::Api { tag, result: Ok(Value::Null) });+ dispatch(&em, "RELATIONSHIP_UPDATE", json!({ "id": id, "type": 1, "nickname": nickname }));+ }+ // Saving account settings (the server list after a drag, …): kept locally.+ Command::Api { tag, path, body: Some(_), .. } if path == "/users/@me/settings-proto/1" => em.emit(Event::Api { tag, result: Ok(json!({})) }),// Your linked accounts (Settings → Connections, and the /fortnite,// /spotify, /roblox… commands).Command::Api { tag, path, .. } if path == "/users/@me/connections" => {diff --git a/apps/rustcord/src/features.rs b/apps/rustcord/src/features.rsindex 09c45cd..55c7bb3 100644--- a/apps/rustcord/src/features.rs+++ b/apps/rustcord/src/features.rs@@ -280,6 +280,8 @@ pub enum ServerDialog {/// pronouns and bio (`None` until your server profile has loaded).Nickname { guild: Id, nick: String, pronouns: Option<String>, bio: Option<String> },LeaveServer { guild: Id },+ /// The channel menu's "Delete Channel" confirmation.+ DeleteChannel { channel: Id, category: bool },}/// What "Add a Server" asks Discord for (kept to send again after a captcha).@@ -1053,11 +1055,17 @@ impl RustCord {pub fn destination_name(&self, channel: Id) -> String {match self.store.channels.get(&channel) {Some(c) if c.guild_id.is_some() => format!("#{}", crate::store::Store::channel_label(c)),- Some(c) => crate::store::Store::channel_label(c),+ Some(c) => self.store.label(c),None => "channel".into(),}}+ /// Whether `channel`'s messages offer "Add Reaction" and the quick+ /// reactions (see [`crate::store::Store::can_add_reactions`]).+ pub fn can_add_reactions(&self, channel: Id) -> bool {+ self.store.channels.get(&channel).is_none_or(|c| self.store.can_add_reactions(c))+ }+/// Whether you may pin and unpin in `channel`: always in DMs and group/// DMs; in a server with Manage Messages or Discord's newer Pin Messages/// (the channel's overwrites applied when we know them).@@ -1266,7 +1274,8 @@ impl RustCord {/// Read a message aloud with the OS speech synthesizer.pub fn speak(&mut self, channel: Id, msg: Id) {let Some(m) = self.store.message(channel, msg) else { return };- let text = format!("{} said {}", m.display_name(), m.content);+ let who = self.store.nick_in(None, Some(channel), m.author.id).unwrap_or_else(|| m.display_name().to_string());+ let text = format!("{who} said {}", m.content);#[cfg(windows)]{use std::os::windows::process::CommandExt;diff --git a/apps/rustcord/src/store.rs b/apps/rustcord/src/store.rsindex 20aaf91..9a7c68b 100644--- a/apps/rustcord/src/store.rs+++ b/apps/rustcord/src/store.rs@@ -212,6 +212,8 @@ pub struct Store {pub read_states: HashMap<Id, ReadState>,pub muted_guilds: HashSet<Id>,pub muted_channels: HashSet<Id>,+ /// When a timed channel mute ends (RFC 3339), for "Muted until …".+ pub channel_mute_until: HashMap<Id, String>,/// Threads we are a member of (Discord lists these under their channel).pub joined_threads: HashSet<Id>,/// DMs pinned to the top of the list. Discord keeps this as the FAVORITED flag@@ -398,6 +400,7 @@ impl Store {// Muted servers / channels.self.muted_guilds.clear();self.muted_channels.clear();+ self.channel_mute_until.clear();self.joined_threads.clear();self.pinned_dms.clear();self.dm_flags.clear();@@ -785,6 +788,29 @@ impl Store {self.channel_perms(ch).map_or(true, |p| p & need != 0)}+ /// Whether you may add new reactions in a channel (Discord's+ /// `disableReactionCreates`, web module 707985): in DMs and group DMs+ /// (not Discord's own system DM) and where you have Add Reactions; never+ /// on media posts, nor in an archived thread you couldn't reopen (locked,+ /// or no Send Messages in Threads). Reacting with a reaction already on a+ /// message needs no permission. Unknown permissions err on yes.+ pub fn can_add_reactions(&self, ch: &Channel) -> bool {+ const ADD_REACTIONS: u64 = 1 << 6;+ const SEND_IN_THREADS: u64 = 1 << 38;+ if ch.kind == channel_kind::MEDIA_THREAD {+ return false;+ }+ if ch.guild_id.is_none() {+ return !(ch.kind == channel_kind::DM && ch.recipients.first().is_some_and(|u| u.system));+ }+ let perms = self.channel_perms(ch);+ let has = |bit: u64| perms.is_none_or(|p| p & bit != 0);+ if channel_kind::is_thread(ch.kind) && ch.archived() && (ch.locked() || !has(SEND_IN_THREADS)) {+ return false;+ }+ has(ADD_REACTIONS)+ }+/// Our permissions in a server channel, overwrites applied (Discord's/// algorithm: @everyone, roles, member). None for DMs or when we don't/// know enough yet.@@ -855,14 +881,26 @@ impl Store {// ---- lookups ----------------------------------------------------------pub fn channel_name(&self, id: Id) -> String {- self.channels.get(&id).map(Self::channel_label).unwrap_or_else(|| "unknown".into())+ self.channels.get(&id).map(|c| self.label(c)).unwrap_or_else(|| "unknown".into())}pub fn channel_label(c: &Channel) -> String {+ Self::label_with(c, |u| u.display_name())+ }++ /// A channel's name as you see it: [`Self::channel_label`], with your+ /// friend nicknames in place of the names of the people in a DM or an+ /// unnamed group (Discord's channel name: the DM list, the chat header,+ /// "Message @…").+ pub fn label<'a>(&'a self, c: &'a Channel) -> String {+ Self::label_with(c, |u| self.friend_nickname(u.id).unwrap_or_else(|| u.display_name()))+ }++ fn label_with<'a>(c: &'a Channel, name: impl Fn(&'a User) -> &'a str) -> String {if let Some(n) = c.name.as_deref().filter(|n| !n.is_empty()) {return n.to_string();}- let names: Vec<&str> = c.recipients.iter().map(User::display_name).collect();+ let names: Vec<&str> = c.recipients.iter().map(name).collect();if names.is_empty() {"Unnamed".into()} else {@@ -870,6 +908,32 @@ impl Store {}}+ /// Your private name for someone (Discord's "Friend Nickname"), shown+ /// instead of theirs in DMs, group DMs and the Friends list.+ pub fn friend_nickname(&self, user: Id) -> Option<&str> {+ self.relationships.get(&user)?.nickname.as_deref().filter(|n| !n.is_empty())+ }++ /// A DM or group DM: where friend nicknames are used.+ pub fn is_dm_channel(&self, channel: Id) -> bool {+ self.channels.get(&channel).is_some_and(|c| matches!(c.kind, channel_kind::DM | channel_kind::GROUP_DM))+ }++ /// Someone's nickname where they're seen (Discord's+ /// NicknameUtils.getNickname): their server nickname in `guild`, else,+ /// in a DM or group DM, your friend nickname for them.+ pub fn nick_in(&self, guild: Option<Id>, channel: Option<Id>, user: Id) -> Option<String> {+ if let Some(g) = guild {+ return self.members.get(&(g, user)).and_then(|m| m.nick.clone()).filter(|n| !n.is_empty());+ }+ channel.filter(|c| self.is_dm_channel(*c)).and_then(|_| self.friend_nickname(user)).map(String::from)+ }++ /// [`Self::nick_in`], else their display name (NicknameUtils.getName).+ pub fn name_in(&self, guild: Option<Id>, channel: Option<Id>, user: &User) -> String {+ self.nick_in(guild, channel, user.id).unwrap_or_else(|| user.display_name().to_string())+ }+pub fn role_name(&self, guild: Option<Id>, role: Id) -> Option<String> {let g = self.guilds.get(&guild?)?;g.guild.roles.iter().find(|r| r.id == role).map(|r| r.name.clone())@@ -1143,6 +1207,10 @@ impl Store {} else {self.muted_channels.remove(&ch);}+ match o["mute_config"]["end_time"].as_str() {+ Some(end) => self.channel_mute_until.insert(ch, end.to_string()),+ None => self.channel_mute_until.remove(&ch),+ };match o["message_notifications"].as_u64() {Some(n @ 0..=2) => {self.channel_notify.insert(ch, n as u8);@@ -1398,11 +1466,25 @@ impl Store {self.presences.get(&user).map_or("offline", |p| p.status.as_str())}+ /// RELATIONSHIP_ADD / RELATIONSHIP_UPDATE. An update replaces the+ /// nickname (one it lacks is gone, as in Discord's store); the user,+ /// `since` and `user_ignored` it leaves out stay as they were.pub fn relationship_add(&mut self, v: &Value) {- if let Ok(rel) = Relationship::deserialize(v) {+ if let Ok(mut rel) = Relationship::deserialize(v) {if let Some(u) = &rel.user {self.users.insert(u.id, u.clone());}+ if let Some(old) = self.relationships.get(&rel.id) {+ if rel.user.is_none() {+ rel.user = old.user.clone();+ }+ if v.get("since").is_none() {+ rel.since = old.since.clone();+ }+ if v.get("user_ignored").is_none() {+ rel.user_ignored = old.user_ignored;+ }+ }self.relationships.insert(rel.id, rel);}}@@ -1630,8 +1712,10 @@ impl Store {if Some(user) == self.me_id() {return;}+ let friend_nick = self.is_dm_channel(ch).then(|| self.friend_nickname(user)).flatten();let name = v["member"]["nick"].as_str()+ .or(friend_nick).or_else(|| v["member"]["user"]["global_name"].as_str()).or_else(|| v["member"]["user"]["username"].as_str()).map(String::from)@@ -1711,6 +1795,73 @@ mod tests {assert!(store.can_open_unasked(Id(10)), "a moderator may be put back in it");}+ /// A friend nickname names them in DMs and group DMs (channel names,+ /// authors, typing) and never in a server, where the server nickname rules.+ #[test]+ fn friend_nicknames_show_only_in_dms() {+ let mut store = Store::default();+ store.me = Some(discord::model::User { id: Id(1), ..Default::default() });+ store.relationship_add(&json!({ "id": "2", "type": 1, "nickname": "Bestie", "user": { "id": "2", "username": "pat", "global_name": "Pat" } }));+ store.relationship_add(&json!({ "id": "3", "type": 1, "nickname": null, "user": { "id": "3", "username": "sam" } }));+ store.add_private_channel(&json!({ "id": "100", "type": 1, "recipient_ids": ["2"] }));+ store.add_private_channel(&json!({ "id": "101", "type": 3, "recipient_ids": ["2", "3"] }));+ let gid = store+ .upsert_guild(&json!({ "id": "500", "name": "Server", "channels": [{ "id": "10", "type": 0, "name": "general", "position": 0 }] }))+ .unwrap();+ let pat = store.users[&Id(2)].clone();++ assert_eq!(store.channel_name(Id(100)), "Bestie");+ assert_eq!(store.channel_name(Id(101)), "Bestie, sam");+ assert_eq!(Store::channel_label(&store.channels[&Id(100)]), "Pat", "the plain label ignores nicknames");+ assert_eq!(store.name_in(None, Some(Id(100)), &pat), "Bestie");+ assert_eq!(store.name_in(Some(gid), Some(Id(10)), &pat), "Pat", "not in a server");+ store.typing_start(&json!({ "channel_id": "100", "user_id": "2" }));+ store.typing_start(&json!({ "channel_id": "10", "user_id": "2", "member": { "user": { "id": "2", "username": "pat", "global_name": "Pat" } } }));+ assert_eq!(store.typing_names(Id(100)), ["Bestie"]);+ assert_eq!(store.typing_names(Id(10)), ["Pat"]);++ // RELATIONSHIP_UPDATE carries no user: the nickname goes, the user stays.+ store.relationship_add(&json!({ "id": "2", "type": 1, "nickname": null }));+ assert_eq!(store.channel_name(Id(100)), "Pat");+ assert!(store.relationships[&Id(2)].user.is_some());+ }++ /// "Add Reaction" follows Discord's rule: DMs yes (not Discord's system+ /// DM), server channels with Add Reactions, archived threads only when+ /// they could be unarchived, media posts never.+ #[test]+ fn reactions_follow_the_permission() {+ let mut store = Store::default();+ store.me = Some(discord::model::User { id: Id(1), ..Default::default() });+ let everyone = (permissions::VIEW_CHANNEL | permissions::SEND_MESSAGES | (1 << 6) | (1 << 38)).to_string();+ let gid = store+ .upsert_guild(&json!({+ "id": "500", "name": "Server",+ "roles": [{ "id": "500", "name": "@everyone", "permissions": everyone, "position": 0 }],+ "channels": [+ { "id": "10", "type": 0, "name": "general", "position": 0 },+ { "id": "11", "type": 0, "name": "no-reactions", "position": 1,+ "permission_overwrites": [{ "id": "500", "type": 0, "allow": "0", "deny": "64" }] },+ ],+ }))+ .unwrap();+ store.my_roles.insert(gid, vec![]);+ for (id, kind, archived, locked) in [(20, 11, false, false), (21, 11, true, false), (22, 11, true, true), (23, 19, false, false)] {+ store.upsert_channel(&json!({ "id": id.to_string(), "type": kind, "guild_id": "500", "parent_id": "10", "name": "thread",+ "thread_metadata": { "archived": archived, "locked": locked } }));+ }+ store.add_private_channel(&json!({ "id": "100", "type": 1, "recipients": [{ "id": "2", "username": "pat" }] }));+ store.add_private_channel(&json!({ "id": "101", "type": 1, "recipients": [{ "id": "3", "username": "Discord", "system": true }] }));+ let can = |id: u64| store.can_add_reactions(&store.channels[&Id(id)]);+ assert!(can(10));+ assert!(!can(11), "Add Reactions denied");+ assert!(can(20) && can(21), "open, or archived but could be reopened");+ assert!(!can(22), "archived and locked");+ assert!(!can(23), "media post");+ assert!(can(100));+ assert!(!can(101), "Discord's system DM");+ }+/// A server's tag comes in its READY `properties.profile` and goes away/// on a GUILD_UPDATE with `profile: null`; it needs the GUILD_TAGS feature.#[test]diff --git a/apps/rustcord/src/style.rs b/apps/rustcord/src/style.rsindex e97364f..0002282 100644--- a/apps/rustcord/src/style.rs+++ b/apps/rustcord/src/style.rs@@ -800,11 +800,31 @@ pub fn install_fonts(ctx: &egui::Context) {("segoe-symbol", "C:\\Windows\\Fonts\\seguisym.ttf", false),("segoe-emoji", "C:\\Windows\\Fonts\\seguiemj.ttf", false),// Other scripts and the decorative characters servers put in- // channel names (・ ┃ ꒰ ୨ etc.); without these they show as boxes.- // Kept to the essentials: every font here stays in RAM. Yu Gothic- // covers Japanese and most Chinese characters.+ // channel and server names (・ ┃ ꒰ ୨ ᐢ ꕤ ༺ 𓍯 etc.); without these+ // they show as boxes. The files are mapped, not read: only the+ // pages a lookup touches are loaded, and those stay Windows' file+ // cache rather than RustCord's own memory (a font's hinter is only+ // made once it draws a glyph). Yu Gothic covers Japanese and most+ // Chinese characters; the fonts after Malgun (Korean) are asked,+ // in this order, for whatever the ones before them lack.("yu-gothic", "C:\\Windows\\Fonts\\YuGothR.ttc", false),("malgun", "C:\\Windows\\Fonts\\malgun.ttf", false),+ // Yi (꒰ ꒱ ꒷) and ﹏.+ ("microsoft-yi-baiti", "C:\\Windows\\Fonts\\msyi.ttf", false),+ // Canadian syllabics (ᐢ ᐟ ᘏ) and Cherokee.+ ("gadugi", "C:\\Windows\\Fonts\\gadugi.ttf", false),+ // Vai (ꕤ ꔫ), N'Ko, Ethiopic, Tifinagh.+ ("ebrima", "C:\\Windows\\Fonts\\ebrima.ttf", false),+ // Historic scripts (𓍯 𐭩), the Bamum supplement (𖦹), Syriac marks.+ ("segoe-ui-historic", "C:\\Windows\\Fonts\\seguihis.ttf", false),+ // Indian scripts beyond the digits Segoe UI has (ৎ ൃ).+ ("nirmala", "C:\\Windows\\Fonts\\Nirmala.ttc", false),+ // Tibetan (༄ ༺ ༻), Tai Le (ᥴ), Mongolian (ᡣ).+ ("himalaya", "C:\\Windows\\Fonts\\himalaya.ttf", false),+ ("tai-le", "C:\\Windows\\Fonts\\taile.ttf", false),+ ("mongolian-baiti", "C:\\Windows\\Fonts\\monbaiti.ttf", false),+ // Windows 11's catch-all for the rest (𐙚 ᭡ ꪆ ᰔ ᯓ 𖹭); Windows 10 lacks it.+ ("sans-serif-collection", "C:\\Windows\\Fonts\\SansSerifCollection.ttf", false),]} else if cfg!(target_os = "linux") {// Symbols and other scripts, where each distribution keeps them@@ -1123,6 +1143,23 @@ mod tests {use eframe::egui::epaint::Fonts;use eframe::egui::{FontFamily, FontId};+ /// The decorative characters servers put in their names (issue #3) have a+ /// font: Yi, Canadian syllabics, Vai, Tibetan, Bengali, historic scripts,+ /// and Windows 11's catch-all for the rest.+ #[cfg(windows)]+ #[test]+ fn decorative_characters_have_a_font() {+ let ctx = eframe::egui::Context::default();+ super::install_fonts(&ctx);+ let _ = ctx.run(Default::default(), |_| {});+ let mut chars = String::from("꒰꒱꒷୨୧⊹⋆⟡ᐢᐟᘏꕤꔫ༄༺༻ৎ𓍯𐭩﹏・┃");+ if std::path::Path::new(r"C:\Windows\Fonts\SansSerifCollection.ttf").exists() {+ chars.push_str("𐙚᭡ꪆᰔᯓ");+ }+ let missing: String = chars.chars().filter(|c| !ctx.fonts(|f| f.has_glyph(&FontId::proportional(16.0), *c))).collect();+ assert!(missing.is_empty(), "no font for {missing}");+ }+/// Hinting makes letters a whole number of pixels tall, as Chrome draws/// Discord's text: the x-height at 16 px is 8 px (7.52 px unhinted)./// `-- --nocapture` prints the glyphs for comparing with Chrome's.diff --git a/apps/rustcord/src/ui/call.rs b/apps/rustcord/src/ui/call.rsindex 0239699..bbde37f 100644--- a/apps/rustcord/src/ui/call.rs+++ b/apps/rustcord/src/ui/call.rs@@ -149,7 +149,7 @@ impl RustCord {let av = Rect::from_center_size(pos2(x + 11.0, cy), vec2(22.0, 22.0));paint_avatar(ui, av, user.as_ref().map(|u| u.avatar_or_default(48)), user.as_ref().map_or("?", |u| u.display_name()));x = av.right() + 8.0;- let nick = gid.and_then(|g| self.store.members.get(&(g, *streamer))).and_then(|m| m.nick.clone());+ let nick = self.store.nick_in(gid, Some(channel), *streamer);let shown = nick.or_else(|| user.as_ref().map(|u| u.display_name().to_string())).unwrap_or_default();let handle = user.as_ref().map(|u| format!(" (@{})", u.username)).unwrap_or_default();let r = paint_text_emoji(ui, &p, pos2(x, cy), &format!("{shown}{handle}"), bold(14.5), t.header_primary);@@ -274,7 +274,7 @@ impl RustCord {ids.into_iter().map(|id| {let user = if Some(id) == me { self.store.me.clone() } else { self.store.users.get(&id).cloned() };- let nick = gid.and_then(|g| self.store.members.get(&(g, id))).and_then(|m| m.nick.clone());+ let nick = self.store.nick_in(gid, Some(channel), id);let name = nick.or_else(|| user.as_ref().map(|u| u.display_name().to_string())).unwrap_or_else(|| "Loading…".into());let profile = self.profiles.get(&(id, gid)).or_else(|| self.profiles.get(&(id, None))).and_then(|r| r.as_ref().ok());let color = profile@@ -892,7 +892,7 @@ impl RustCord {let there = self.store.voice.get(&channel).cloned().unwrap_or_default();c.recipients.iter().find(|u| there.contains(&u.id)).or(c.recipients.first()).cloned()});- let name = chan.as_ref().map(crate::store::Store::channel_label).unwrap_or_else(|| "Unknown".into());+ let name = chan.as_ref().map(|c| self.store.label(c)).unwrap_or_else(|| "Unknown".into());let (mut accept, mut decline) = (false, false);egui::Area::new(egui::Id::new("incoming_call")).order(Order::Foreground).anchor(Align2::CENTER_CENTER, vec2(0.0, 0.0)).show(ctx, |ui| {egui::Frame::none()diff --git a/apps/rustcord/src/ui/channel_menu.rs b/apps/rustcord/src/ui/channel_menu.rsnew file mode 100644index 0000000..df871e9--- /dev/null+++ b/apps/rustcord/src/ui/channel_menu.rs@@ -0,0 +1,199 @@+//! A server channel's right-click menu, and the channel mute and+//! notification actions it shares with the voice call's bell menu. Items,+//! order and strings follow Discord's web app (read 2026-12-03); Discord's+//! Add to Favorites, Pin Channel to Top, Move to…, Duplicate Channel and+//! Hide Names aren't here yet.++use super::guild_menu::{draw_menu, item, level_label, mute_until_label, sub_path_id, Row, MUTE_TIMES};+use crate::app::RustCord;+use crate::style::icon;+use discord::model::{channel_kind, permissions, Id};+use eframe::egui::{self, Key, Pos2, Rect};+use serde_json::json;++/// Something a channel menu row does.+#[derive(Clone, Copy, PartialEq, Debug)]+pub enum ChannelAct {+ MarkRead,+ Invite,+ CopyLink,+ OpenChat,+ /// Mute for this many seconds (-1: until unmuted).+ Mute(i64),+ Unmute,+ /// 0 all, 1 @mentions, 2 nothing, 3 the category's (or server's) setting.+ Notify(u8),+ Edit,+ /// Create a channel of this kind beside it (0 text, 2 voice).+ Create(u8),+ Delete,+ CopyId,+}++impl RustCord {+ /// Right-click on a channel in the server's channel list.+ pub fn open_channel_menu(&mut self, channel: Id, at: Pos2) {+ self.server_menu = None;+ self.guild_menu = None;+ self.channel_menu = Some((channel, at, self.ctx.cumulative_pass_nr()));+ self.ctx.data_mut(|d| d.remove::<Vec<usize>>(sub_path_id()));+ }++ /// Discord's channel context menu (called every frame).+ pub fn channel_menu_ui(&mut self, ctx: &egui::Context) {+ let Some((ch, at, opened)) = self.channel_menu else { return };+ let Some(rows) = self.channel_menu_rows(ch) else {+ self.channel_menu = None;+ return;+ };+ let t = self.theme.clone();+ let mut picked = None;+ let mut rects = Vec::new();+ draw_menu(ctx, &t, egui::Id::new("channel_menu"), at, &rows, 0, &mut picked, &mut rects);+ let now = ctx.cumulative_pass_nr();+ let outside = now > opened + 1+ && ctx.input(|i| i.pointer.any_pressed() && i.pointer.interact_pos().is_some_and(|p| !rects.iter().any(|r: &Rect| r.contains(p))));+ if picked.is_some() || outside || ctx.input(|i| i.key_pressed(Key::Escape)) {+ self.channel_menu = None;+ }+ if let Some(act) = picked {+ self.channel_act(ch, act);+ }+ }++ /// The menu's rows for `ch`, from your permissions there and your+ /// notification settings. None once the channel is gone.+ fn channel_menu_rows(&self, ch: Id) -> Option<Vec<Row<ChannelAct>>> {+ let c = self.store.channels.get(&ch)?;+ c.guild_id?;+ let voice = channel_kind::is_voice(c.kind);+ let perms = self.store.channel_perms(c).unwrap_or(0);+ let has = |p: u64| perms & p != 0;+ let unread = self.store.is_unread(ch) || self.store.mentions(ch) > 0;+ let mut rows = Vec::new();++ rows.push(Row::Item { glyph: None, label: "Mark As Read".into(), sub: None, act: ChannelAct::MarkRead, danger: false, enabled: unread });+ rows.push(Row::Sep);+ if has(permissions::CREATE_INSTANT_INVITE) {+ rows.push(item(None, if voice { "Invite to Voice" } else { "Invite to Channel" }, ChannelAct::Invite));+ }+ rows.push(item(None, "Copy Link", ChannelAct::CopyLink));+ rows.push(Row::Sep);+ if voice {+ rows.push(item(None, "Open Chat", ChannelAct::OpenChat));+ rows.push(Row::Sep);+ }+ if self.store.muted_channels.contains(&ch) {+ let sub = self.store.channel_mute_until.get(&ch).and_then(|end| mute_until_label(end));+ rows.push(Row::Item { glyph: None, label: "Unmute Channel".into(), sub, act: ChannelAct::Unmute, danger: false, enabled: true });+ } else {+ let times = MUTE_TIMES.iter().map(|(s, l)| item(None, l, ChannelAct::Mute(*s))).collect();+ rows.push(Row::Sub { glyph: None, label: "Mute Channel".into(), sub: None, rows: times });+ }+ // Voice channels have no Notification Settings in Discord's menu.+ if !voice {+ let own = self.store.channel_notify.get(&ch).copied();+ let inherited = self.inherited_notify(ch);+ let mut levels = vec![Row::Radio {+ label: "Use Category Default".into(),+ sub: Some(level_label(inherited).into()),+ on: own.is_none(),+ act: ChannelAct::Notify(3),+ }];+ for (v, label) in [(0u8, "All Messages"), (1, "Only @mentions"), (2, "Nothing")] {+ levels.push(Row::Radio { label: label.into(), sub: None, on: own == Some(v), act: ChannelAct::Notify(v) });+ }+ let current = level_label(own.unwrap_or(inherited));+ rows.push(Row::Sub { glyph: None, label: "Notification Settings".into(), sub: Some(current.into()), rows: levels });+ }+ if has(permissions::MANAGE_CHANNELS) {+ rows.push(Row::Sep);+ rows.push(item(None, "Edit Channel", ChannelAct::Edit));+ let kind = if voice { 2 } else { 0 };+ rows.push(item(None, if voice { "Create Voice Channel" } else { "Create Text Channel" }, ChannelAct::Create(kind)));+ rows.push(Row::Item { glyph: None, label: "Delete Channel".into(), sub: None, act: ChannelAct::Delete, danger: true, enabled: true });+ }+ rows.push(Row::Sep);+ rows.push(item(Some(icon::ID), "Copy Channel ID", ChannelAct::CopyId));+ Some(rows)+ }++ /// The level a channel without its own setting follows: its category's,+ /// else the server's.+ fn inherited_notify(&self, ch: Id) -> u8 {+ let c = self.store.channels.get(&ch);+ let category = c.and_then(|c| c.parent_id).and_then(|p| self.store.channel_notify.get(&p).copied());+ category.or_else(|| c.and_then(|c| c.guild_id).and_then(|g| self.store.notify_level.get(&g).copied())).unwrap_or(0)+ }++ /// Do what a channel menu row asked.+ fn channel_act(&mut self, ch: Id, act: ChannelAct) {+ let Some(c) = self.store.channels.get(&ch) else { return };+ let (guild, parent, kind) = (c.guild_id, c.parent_id, c.kind);+ match act {+ ChannelAct::MarkRead => self.mark_channel_read(ch),+ ChannelAct::Invite => self.open_invite(ch),+ ChannelAct::CopyLink => {+ let g = guild.map_or_else(|| "@me".to_string(), |g| g.to_string());+ self.ctx.copy_text(format!("https://discord.com/channels/{g}/{ch}"));+ self.toast("Link copied.", false);+ }+ ChannelAct::OpenChat => {+ self.guild_pages.open = None;+ self.select_channel(Some(ch));+ self.golive_ui.chat_open = true;+ }+ ChannelAct::Mute(secs) => self.mute_channel(ch, Some(secs)),+ ChannelAct::Unmute => self.mute_channel(ch, None),+ ChannelAct::Notify(n) => self.set_channel_notify(ch, n),+ ChannelAct::Edit => self.open_channel_settings(ch),+ ChannelAct::Create(kind) => {+ if let Some(guild) = guild {+ self.server_dialog = Some(crate::features::ServerDialog::CreateChannel { guild, parent, name: String::new(), kind, private: false, category: false });+ }+ }+ ChannelAct::Delete => self.server_dialog = Some(crate::features::ServerDialog::DeleteChannel { channel: ch, category: kind == channel_kind::GUILD_CATEGORY }),+ ChannelAct::CopyId => {+ self.ctx.copy_text(ch.to_string());+ self.toast("Channel ID copied.", false);+ }+ }+ }++ /// Mute a server channel for `secs` seconds (-1: until unmuted), or+ /// unmute it (None), here and on Discord.+ pub fn mute_channel(&mut self, ch: Id, secs: Option<i64>) {+ let Some(g) = self.store.channels.get(&ch).and_then(|c| c.guild_id) else { return };+ let over = match secs {+ None => {+ self.store.muted_channels.remove(&ch);+ self.store.channel_mute_until.remove(&ch);+ json!({ "muted": false })+ }+ Some(secs) => {+ self.store.muted_channels.insert(ch);+ let end = (secs > 0).then(|| (chrono::Utc::now() + chrono::Duration::seconds(secs)).to_rfc3339_opts(chrono::SecondsFormat::Millis, true));+ match &end {+ Some(e) => self.store.channel_mute_until.insert(ch, e.clone()),+ None => self.store.channel_mute_until.remove(&ch),+ };+ json!({ "muted": true, "mute_config": { "selected_time_window": secs, "end_time": end } })+ }+ };+ let patch = json!({ "channel_overrides": { ch.to_string(): over } });+ self.backend.send(crate::backend::Command::GuildSettings { guild: g, patch });+ }++ /// A server channel's notification level (3: back to the category's or+ /// server's), here and on Discord.+ pub fn set_channel_notify(&mut self, ch: Id, n: u8) {+ let Some(g) = self.store.channels.get(&ch).and_then(|c| c.guild_id) else { return };+ if n == 3 {+ self.store.channel_notify.remove(&ch);+ } else {+ self.store.channel_notify.insert(ch, n);+ }+ let patch = json!({ "channel_overrides": { ch.to_string(): { "message_notifications": n } } });+ self.backend.send(crate::backend::Command::GuildSettings { guild: g, patch });+ }+}diff --git a/apps/rustcord/src/ui/chat.rs b/apps/rustcord/src/ui/chat.rsindex 445a51d..90ebf3a 100644--- a/apps/rustcord/src/ui/chat.rs+++ b/apps/rustcord/src/ui/chat.rs@@ -108,7 +108,7 @@ fn code_fill() -> Color32 {/// Discord's system messages (joins, pins, boosts, thread and poll notices):/// an icon in the avatar gutter, one muted line with the time after it.fn is_system(m: &Message) -> bool {- !matches!(m.kind, 0 | 19 | 20 | 23 | 24) && (matches!(m.kind, 18 | 46 | FRIEND_REQUEST_ACCEPTED) || system_text(m).is_some())+ !matches!(m.kind, 0 | 19 | 20 | 23 | 24) && (matches!(m.kind, 18 | 46 | FRIEND_REQUEST_ACCEPTED) || system_text(m, m.display_name()).is_some())}/// Discord's FRIEND_REQUEST_ACCEPTED message (type 67), the first thing in a@@ -409,8 +409,8 @@ fn reply_placeholder(r: &Message) -> Option<&'static str> {Some(if r.attachments.is_empty() && r.embeds.is_empty() && !r.sticker_items.is_empty() { "Click to see sticker" } else { "Click to see attachment" })}-fn system_text(m: &Message) -> Option<String> {- let who = m.display_name();+/// `who` is the author as the channel names them (server or friend nickname).+fn system_text(m: &Message, who: &str) -> Option<String> {Some(match m.kind {0 | 19 | 20 | 23 => return None,1 => format!("{who} added someone to the group."),@@ -449,8 +449,7 @@ fn lasted(secs: i64) -> String {/// A DM call's line, and whether it is one you missed: "X started a call." while it/// runs, then "X started a call that lasted …" or "You missed a call from X that lasted …".-fn call_text(m: &Message, me: Option<Id>) -> (String, bool) {- let who = m.display_name();+fn call_text(m: &Message, who: &str, me: Option<Id>) -> (String, bool) {let seconds = m.call.as_ref().and_then(|c| c.ended_timestamp.as_deref()).and_then(|end| {let start = chrono::DateTime::parse_from_rfc3339(&m.timestamp).ok()?;let end = chrono::DateTime::parse_from_rfc3339(end).ok()?;@@ -717,7 +716,7 @@ impl RustCord {return;};let Some(channel) = self.store.channels.get(&ch).cloned() else { return };- let name = Store::channel_label(&channel);+ let name = self.store.label(&channel);self.message_select_input(ch);let (mut open_pins, mut toggle_members, mut do_search, mut toggle_profile) = (false, false, false, false);@@ -1027,7 +1026,7 @@ impl RustCord {pub(super) fn voice_chat_panel(&mut self, ui: &mut Ui, ch: Id) -> bool {let t = self.theme.clone();let Some(channel) = self.store.channels.get(&ch).cloned() else { return true };- let name = Store::channel_label(&channel);+ let name = self.store.label(&channel);let mut close = false;ui.painter().rect_filled(ui.max_rect(), 0.0, t.bg_primary);TopBottomPanel::top("vc_chat_header")@@ -1104,7 +1103,7 @@ impl RustCord {.iter().filter(|m| self.picked_msgs.1.contains(&m.id)).map(|m| {- let mut text = if m.content.is_empty() { system_text(m).unwrap_or_default() } else { m.content.clone() };+ let mut text = if m.content.is_empty() { system_text(m, &self.author_name(m)).unwrap_or_default() } else { m.content.clone() };for a in &m.attachments {if !text.is_empty() {text.push('\n');@@ -1476,7 +1475,7 @@ impl RustCord {let tag = format!("greet:{ch}");let busy = self.api_pending.contains(&tag);let error = self.api_results.get(&tag).and_then(|r| r.as_ref().err());- let name = if channel.recipients.is_empty() { "your mate".to_string() } else { Store::channel_label(channel) };+ let name = if channel.recipients.is_empty() { "your mate".to_string() } else { self.store.label(channel) };let label = format!("Wave to {name}");let font = crate::style::medium(16.0);// Discord's "Play sticker animations": 0 always, 1 on hover, 2 never.@@ -2004,8 +2003,10 @@ impl RustCord {let mut tools = Vec::new();let quick = self.quick_reactions(3);if live {- tools.extend(quick.iter().map(|e| Tool::React(e.as_str())));- tools.push(Tool::AddReaction);+ if self.can_add_reactions(m.channel_id) {+ tools.extend(quick.iter().map(|e| Tool::React(e.as_str())));+ tools.push(Tool::AddReaction);+ }tools.push(Tool::Reply);tools.push(Tool::Forward);if Some(m.author.id) == me {@@ -2385,12 +2386,24 @@ impl RustCord {}}- /// Server nickname, else display name.+ /// A system message's line ("X started a call.") and the author's name in it.+ fn system_line(&self, m: &Message) -> Option<(String, String)> {+ if matches!(m.kind, 0 | 19 | 20 | 23) {+ return None;+ }+ let who = self.author_name(m);+ let line = system_text(m, &who)?;+ Some((if m.kind == 3 { call_text(m, &who, self.store.me_id()).0 } else { line }, who))+ }++ /// Server nickname in a server, friend nickname in a DM, else display name.pub(super) fn author_name(&self, m: &Message) -> String {- let nick = m.member.as_ref().and_then(|mem| mem.nick.clone()).or_else(|| {- self.guild_of(m).and_then(|g| self.store.members.get(&(g, m.author.id))).and_then(|i| i.nick.clone())- });- nick.unwrap_or_else(|| m.author.display_name().to_string())+ m.member+ .as_ref()+ .and_then(|mem| mem.nick.clone())+ .filter(|n| !n.is_empty())+ .or_else(|| self.store.nick_in(self.guild_of(m), Some(m.channel_id), m.author.id))+ .unwrap_or_else(|| m.author.display_name().to_string())}/// `<@id>`, `<#id>`, `<@&id>` and `<:emoji:id>` as Discord shows them in@@ -2486,7 +2499,7 @@ impl RustCord {};if is_system(m) {let (rect, _) = ui.allocate_exact_size(vec2(20.0, line), Sense::hover());- let kind = if m.kind == 3 && call_text(m, self.store.me_id()).1 { MISSED_CALL } else { m.kind };+ let kind = if m.kind == 3 && call_text(m, "", self.store.me_id()).1 { MISSED_CALL } else { m.kind };system_icon(ui, t, kind, rect);} else {if super::COMPACT_AVATARS.load(std::sync::atomic::Ordering::Relaxed) {@@ -2646,7 +2659,7 @@ impl RustCord {} else if system {// The gutter icon, level with the 22 px line.let (rect, _) = ui.allocate_exact_size(vec2(40.0, 22.0), Sense::hover());- let kind = if m.kind == 3 && call_text(m, self.store.me_id()).1 { MISSED_CALL } else { m.kind };+ let kind = if m.kind == 3 && call_text(m, "", self.store.me_id()).1 { MISSED_CALL } else { m.kind };system_icon(ui, t, kind, rect);} else {let (rect, resp) = ui.allocate_exact_size(vec2(40.0, 40.0), Sense::click());@@ -2941,8 +2954,7 @@ impl RustCord {self.rich_system_message(ui, m, actions);} else if m.kind == 6 {self.pin_notice(ui, m, actions);- } else if let Some(sys) = system_text(m).map(|s| if m.kind == 3 { call_text(m, self.store.me_id()).0 } else { s }) {- let who = m.display_name().to_string();+ } else if let Some((sys, who)) = self.system_line(m) {ui.horizontal_wrapped(|ui| {ui.spacing_mut().item_spacing.x = 0.0;match sys.strip_prefix(&who) {@@ -3115,7 +3127,7 @@ impl RustCord {// the pointer is over the row.let row_id = egui::Id::new(("reactions_row", m.id.0));let was: Option<Rect> = ui.ctx().data(|d| d.get_temp(row_id));- if was.is_some_and(|r| ui.rect_contains_pointer(r.expand(2.0))) && self.context_menu.is_none() {+ if was.is_some_and(|r| ui.rect_contains_pointer(r.expand(2.0))) && self.context_menu.is_none() && self.can_add_reactions(m.channel_id) {let (r, b) = ui.allocate_exact_size(vec2(26.0, 30.0), Sense::click());ui.painter().text(r.center(), Align2::CENTER_CENTER, icon::EMOJI, icon_font(16.0), if b.hovered() { t.interactive_hover } else { t.interactive_normal });if b.on_hover_cursor(CursorIcon::PointingHand).on_hover_text("Add Reaction").clicked() {@@ -3363,12 +3375,13 @@ impl RustCord {widest}+ /// A mentioned user as this channel names them.fn user_name(&self, m: &Message, id: Id) -> String {m.mentions.iter().find(|u| u.id == id).or_else(|| self.store.users.get(&id))- .map(|u| u.display_name().to_string())+ .map(|u| self.store.name_in(self.guild_of(m), Some(m.channel_id), u)).unwrap_or_else(|| "unknown-user".into())}@@ -4273,6 +4286,7 @@ impl RustCord {let mine = Some(m.author.id) == self.store.me_id();let live = !m.meta.deleted && !m.meta.pending && !m.meta.failed;let can_pin = self.can_pin(cm.channel);+ let can_react = self.can_add_reactions(cm.channel);// Moderators (Manage Messages in the channel) delete anyone's messages.const MANAGE_MESSAGES: u64 = 1 << 13;let moderates = self.store.channels.get(&cm.channel).and_then(|c| Some((c.guild_id?, self.store.channel_perms(c)))).is_some_and(|(g, p)| match p {@@ -4319,25 +4333,28 @@ impl RustCord {ui.set_width(204.0);ui.spacing_mut().item_spacing.y = 1.0;if live {- // Frequently used reactions.- ui.horizontal(|ui| {- ui.spacing_mut().item_spacing.x = 6.0;- for e in &quick {- let (r, b) = ui.allocate_exact_size(vec2(46.5, 44.0), Sense::click());- ui.painter().rect_filled(r, 8.0, if b.hovered() { t.bg_hover } else { t.bg_secondary });- let s = if b.hovered() { 26.0 } else { 24.0 };- egui::Image::new(twemoji_url(e)).paint_at(ui, Rect::from_center_size(r.center(), vec2(s, s)));- if b.clicked() {- choice = Some(Choice::React(e.clone()));+ // Frequently used reactions and "Add Reaction", where you+ // may add new ones (Discord leaves both out elsewhere).+ if can_react {+ ui.horizontal(|ui| {+ ui.spacing_mut().item_spacing.x = 6.0;+ for e in &quick {+ let (r, b) = ui.allocate_exact_size(vec2(46.5, 44.0), Sense::click());+ ui.painter().rect_filled(r, 8.0, if b.hovered() { t.bg_hover } else { t.bg_secondary });+ let s = if b.hovered() { 26.0 } else { 24.0 };+ egui::Image::new(twemoji_url(e)).paint_at(ui, Rect::from_center_size(r.center(), vec2(s, s)));+ if b.clicked() {+ choice = Some(Choice::React(e.clone()));+ }}+ });+ ui.add_space(6.0);+ let r = menu_row(ui, &t, icon::EMOJI, "Add Reaction", false, true);+ if r.clicked() {+ choice = Some(Choice::AddReaction(r.rect.right_top()));}- });- ui.add_space(6.0);- let r = menu_row(ui, &t, icon::EMOJI, "Add Reaction", false, true);- if r.clicked() {- choice = Some(Choice::AddReaction(r.rect.right_top()));+ menu_separator(ui, &t);}- menu_separator(ui, &t);if mine && menu_row(ui, &t, icon::EDIT, "Edit Message", false, false).clicked() {choice = Some(Choice::Edit);}@@ -4484,7 +4501,7 @@ impl RustCord {let dm = self.store.channels.get(&m.channel_id).filter(|c| c.kind == channel_kind::DM);let other = dm.and_then(|c| c.recipients.first()).cloned().or_else(|| (!mine).then(|| m.author.clone()));let name = match (dm, &other) {- (Some(c), _) => Store::channel_label(c),+ (Some(c), _) => self.store.label(c),(None, Some(u)) => u.display_name().to_string(),(None, None) => "Someone".to_string(),};diff --git a/apps/rustcord/src/ui/friend_nickname.rs b/apps/rustcord/src/ui/friend_nickname.rsnew file mode 100644index 0000000..f871b09--- /dev/null+++ b/apps/rustcord/src/ui/friend_nickname.rs@@ -0,0 +1,186 @@+//! Discord's friend nicknames: a private name for a friend, seen only by you+//! in DMs, group DMs and the Friends list (`Store::nick_in`). Set from+//! "Add Friend Nickname" / "Change Friend Nickname" in the user menus, with+//! Discord's dialog (web module 609422), saved with+//! `PATCH /users/@me/relationships/{id} {"nickname": …}`.++use crate::app::RustCord;+use crate::style::{icon, icon_font, medium, overlay, rgba};+use discord::model::{Id, User};+use eframe::egui::{self, pos2, vec2, Align2, Color32, CursorIcon, FontId, Key, Margin, Rect, Sense, Stroke, TextEdit};+use serde_json::{json, Value};++/// The dialog while it is up.+pub struct FriendNickname {+ user: User,+ /// What the field holds; empty saves "no nickname".+ value: String,+ /// They had a nickname when it opened ("Change", not "Add").+ had: bool,+ /// Frame it opened on (Save takes the keyboard focus then).+ opened: u64,+}++const TITLE_ADD: &str = "Add Friend Nickname";+const TITLE_CHANGE: &str = "Change Friend Nickname";+const SUBTITLE: &str = "Find a friend faster with a personal nickname. It will only be visible to you in your direct messages.";+/// Discord's limit on the field.+const MAX_CHARS: usize = 32;+const BRAND: Color32 = Color32::from_rgb(0x58, 0x65, 0xf2);+const BRAND_HOVER: Color32 = Color32::from_rgb(0x47, 0x52, 0xc4);+/// `--text-brand` in Discord's dark themes (the "Reset Friend Nickname" link).+const TEXT_BRAND: Color32 = Color32::from_rgb(0x63, 0x74, 0xf4);+/// `--text-brand` in the light theme.+const TEXT_BRAND_LIGHT: Color32 = Color32::from_rgb(0x46, 0x4c, 0xd5);++fn tag(user: Id) -> String {+ format!("friend-nick:{user}")+}++impl RustCord {+ /// The user menus' row for `user`: "Add Friend Nickname", or "Change+ /// Friend Nickname" once they have one; None for anyone not a friend.+ pub fn friend_nickname_row(&self, user: Id) -> Option<&'static str> {+ let rel = self.store.relationships.get(&user).filter(|r| r.kind == 1)?;+ Some(if rel.nickname.as_deref().is_some_and(|n| !n.is_empty()) { TITLE_CHANGE } else { TITLE_ADD })+ }++ pub fn open_friend_nickname(&mut self, user: Id) {+ let rel_user = self.store.relationships.get(&user).and_then(|r| r.user.clone());+ let Some(u) = self.store.users.get(&user).cloned().or(rel_user) else { return };+ let current = self.store.friend_nickname(user).map(String::from);+ self.api_results.remove(&tag(user));+ self.friend_nickname = Some(FriendNickname { user: u, had: current.is_some(), value: current.unwrap_or_default(), opened: self.ctx.cumulative_pass_nr() });+ }++ /// Discord's dialog, measured on Discord web (2026-12-03): 480 px wide,+ /// 12 px corners; 20/24 semibold title 24 px in and a 40 px close button 8 px+ /// from the corner; the 16/20 subtitle (`--text-subtle`) 8 px under the+ /// title; 16 px on, the 16/20 medium "Friend Nickname" label, 8 px, the+ /// 40 px field, 8 px, the 14/18 "Reset Friend Nickname" link; 16 px on,+ /// Cancel / Save (40 px, 8 px apart) sharing the width, 24 px from the+ /// bottom. Save holds the keyboard focus as it opens, so Enter saves (from+ /// the field too); Esc, ✕, Cancel or a click on the dimmed window closes+ /// without saving.+ pub fn friend_nickname_ui(&mut self, ctx: &egui::Context) {+ self.friend_nickname_results();+ let Some(dialog) = self.friend_nickname.as_mut() else { return };+ let t = self.theme.clone();+ let uid = dialog.user.id;+ let tag = tag(uid);+ let saving = self.api_pending.contains(&tag);+ const W: f32 = 478.0;+ let field_id = egui::Id::new(("friend_nickname_field", uid.0));+ let save_id = egui::Id::new("friend_nickname_save");+ if ctx.cumulative_pass_nr() <= dialog.opened + 1 {+ ctx.memory_mut(|m| m.request_focus(save_id));+ }+ let enter = ctx.input(|i| i.key_pressed(Key::Enter));+ let mut close = ctx.input(|i| i.key_pressed(Key::Escape));+ let mut save = enter && ctx.memory(|m| m.has_focus(save_id));+ close |= super::guild_pages::modal_frame(ctx, &t, "friend_nickname", W, |ui| {+ let mut job = egui::text::LayoutJob::single_section(+ SUBTITLE.into(),+ egui::TextFormat { font_id: FontId::proportional(16.0), color: t.header_secondary, line_height: Some(20.0), ..Default::default() },+ );+ job.wrap.max_width = W - 48.0;+ let subtitle = ui.fonts(|f| f.layout_job(job));+ let sub_h = subtitle.size().y;+ let h = 56.0 + sub_h + 8.0 + 16.0 + 20.0 + 8.0 + 40.0 + 8.0 + 18.0 + 8.0 + 16.0 + 40.0 + 8.0 + 16.0;+ let (r, _) = ui.allocate_exact_size(vec2(W, h), Sense::hover());+ let left = r.left() + 24.0;+ let title = if dialog.had { TITLE_CHANGE } else { TITLE_ADD };+ ui.painter().text(pos2(left, r.top() + 36.0), Align2::LEFT_CENTER, title, super::guild_pages::strong(20.0), t.header_primary);++ let x = Rect::from_min_size(pos2(r.right() - 8.0 - 40.0, r.top() + 8.0), vec2(40.0, 40.0));+ let xr = ui.interact(x, egui::Id::new("friend_nickname_close"), Sense::click()).on_hover_cursor(CursorIcon::PointingHand);+ if xr.hovered() {+ ui.painter().rect_filled(x, 8.0, t.bg_hover);+ }+ ui.painter().text(x.center(), Align2::CENTER_CENTER, icon::CLOSE, icon_font(14.0), if xr.hovered() { t.header_primary } else { t.interactive_normal });+ close |= xr.clicked();+ ui.painter().galley(pos2(left, r.top() + 56.0), subtitle, t.header_secondary);++ // The field, under its label.+ let label_top = r.top() + 56.0 + sub_h + 8.0 + 16.0;+ ui.painter().text(pos2(left, label_top + 10.0), Align2::LEFT_CENTER, "Friend Nickname", medium(16.0), t.header_primary);+ let field = Rect::from_min_size(pos2(left, label_top + 28.0), vec2(W - 48.0, 40.0));+ let focused = ui.memory(|m| m.has_focus(field_id));+ ui.painter().rect(field, 8.0, Color32::from_black_alpha(31), Stroke::new(1.0_f32, if focused { t.text_link } else { rgba(151, 151, 159, 61) }));+ let edit = TextEdit::singleline(&mut dialog.value)+ .id(field_id)+ .frame(false)+ .margin(Margin::symmetric(0.0, 0.0))+ .hint_text(egui::RichText::new(dialog.user.display_name()).color(t.text_muted))+ .char_limit(MAX_CHARS)+ .font(FontId::proportional(16.0))+ .text_color(t.text_normal)+ .vertical_align(egui::Align::Center);+ let resp = ui.put(field.shrink2(vec2(12.0, 1.0)), edit);+ save |= resp.lost_focus() && enter;++ // "Reset Friend Nickname": empties the field and gives it the focus back.+ let link_color = if t.light { TEXT_BRAND_LIGHT } else { TEXT_BRAND };+ let galley = ui.painter().layout_no_wrap("Reset Friend Nickname".into(), medium(14.0), link_color);+ let link = Rect::from_min_size(pos2(left, field.bottom() + 8.0), vec2(galley.size().x, 18.0));+ let lr = ui.interact(link, egui::Id::new("friend_nickname_reset"), Sense::click()).on_hover_cursor(CursorIcon::PointingHand);+ let text_pos = pos2(link.left(), link.center().y - galley.size().y / 2.0);+ if lr.hovered() {+ let y = link.bottom() - 2.0;+ ui.painter().hline(link.x_range(), y, Stroke::new(1.0_f32, link_color));+ }+ ui.painter().galley(text_pos, galley, link_color);+ if lr.clicked() {+ dialog.value.clear();+ ui.memory_mut(|m| m.request_focus(field_id));+ }++ // Cancel / Save.+ let bw = (W - 48.0 - 8.0) / 2.0;+ let no = Rect::from_min_size(pos2(left, r.bottom() - 24.0 - 40.0), vec2(bw, 40.0));+ let yes = no.translate(vec2(bw + 8.0, 0.0));+ let nr = ui.interact(no, egui::Id::new("friend_nickname_cancel"), Sense::click()).on_hover_cursor(CursorIcon::PointingHand);+ ui.painter().rect(no, 8.0, overlay(if nr.hovered() { 0.2 } else { 0.12 }), Stroke::new(1.0_f32, rgba(151, 151, 159, 41)));+ ui.painter().text(no.center(), Align2::CENTER_CENTER, "Cancel", medium(16.0), t.header_primary);+ close |= nr.clicked();+ let yr = ui.interact(yes, save_id, if saving { Sense::hover() } else { Sense::click() });+ let fill = if yr.hovered() && !saving { BRAND_HOVER } else { BRAND };+ ui.painter().rect(yes, 8.0, if saving { fill.gamma_multiply(0.5) } else { fill }, Stroke::new(1.0_f32, rgba(255, 255, 255, 20)));+ ui.painter().text(yes.center(), Align2::CENTER_CENTER, "Save", medium(16.0), if saving { Color32::from_white_alpha(128) } else { Color32::WHITE });+ save |= yr.on_hover_cursor(CursorIcon::PointingHand).clicked();+ });++ if save && !saving {+ let nickname = dialog.value.trim().to_string();+ let value = if nickname.is_empty() { Value::Null } else { json!(nickname) };+ self.api(&tag, reqwest::Method::PATCH, format!("/users/@me/relationships/{uid}"), Some(json!({ "nickname": value })));+ } else if close {+ ctx.memory_mut(|m| {+ m.surrender_focus(save_id);+ m.surrender_focus(field_id);+ });+ self.friend_nickname = None;+ }+ }++ /// Answers to the dialog's save: shown at once (Discord's own+ /// RELATIONSHIP_UPDATE confirms it shortly after) and the dialog closes;+ /// on an error it stays open, with the reason in a toast.+ fn friend_nickname_results(&mut self) {+ let Some(uid) = self.friend_nickname.as_ref().map(|d| d.user.id) else { return };+ match self.api_take(&tag(uid)) {+ Some(Ok(_)) => {+ let nickname = self.friend_nickname.take().map(|d| d.value.trim().to_string()).unwrap_or_default();+ self.set_friend_nickname_locally(uid, &nickname);+ }+ Some(Err(e)) => self.toast(format!("Couldn't save the friend nickname: {e}"), true),+ None => {}+ }+ }++ fn set_friend_nickname_locally(&mut self, user: Id, nickname: &str) {+ if let Some(rel) = self.store.relationships.get_mut(&user) {+ rel.nickname = (!nickname.is_empty()).then(|| nickname.to_string());+ }+ }+}diff --git a/apps/rustcord/src/ui/friends.rs b/apps/rustcord/src/ui/friends.rsindex 98bc6fc..c2231d8 100644--- a/apps/rustcord/src/ui/friends.rs+++ b/apps/rustcord/src/ui/friends.rs@@ -210,8 +210,8 @@ struct GameCard {impl RustCord {fn friend_name(&self, id: Id) -> String {- if let Some(n) = self.store.relationships.get(&id).and_then(|r| r.nickname.clone()) {- return n;+ if let Some(n) = self.store.friend_nickname(id) {+ return n.to_string();}self.store.users.get(&id).map(|u| u.display_name().to_string()).unwrap_or_else(|| "Unknown".into())}@@ -568,7 +568,8 @@ impl RustCord {let Some((user, pos, opened, confirm)) = self.friend_menu else { return };let t = self.theme.clone();let name = self.friend_name(user);- // 0 profile, 1 message, 2 remove (asks), 3 confirmed remove, 4 cancel, 5 copy id+ let nickname_row = self.friend_nickname_row(user);+ // 0 profile, 1 message, 2 remove (asks), 3 confirmed remove, 4 cancel, 5 copy id, 6 friend nicknamelet mut pick: Option<u8> = None;let area = egui::Area::new(egui::Id::new("friend_menu")).order(Order::Foreground)@@ -619,6 +620,9 @@ impl RustCord {};row(ui, icon::PROFILE, "Profile", false, 0);row(ui, icon::MESSAGE, "Message", false, 1);+ if let Some(label) = nickname_row {+ row(ui, icon::EDIT, label, false, 6);+ }row(ui, icon::ID, "Copy User ID", false, 5);ui.add_space(4.0);let y = ui.cursor().top();@@ -653,6 +657,10 @@ impl RustCord {self.friend_menu = None;ctx.copy_text(user.to_string());}+ Some(6) => {+ self.friend_menu = None;+ self.open_friend_nickname(user);+ }Some(_) => self.friend_menu = None,}}@@ -1002,7 +1010,7 @@ impl RustCord {if let Some(channel) = preview {let pid = channel.id;self.ensure_loaded(pid);- let name = crate::store::Store::channel_label(&channel);+ let name = self.store.label(&channel);let user = channel.recipients.first().cloned().unwrap_or_default();let mut close = false;SidePanel::right("request_preview")diff --git a/apps/rustcord/src/ui/guild_menu.rs b/apps/rustcord/src/ui/guild_menu.rsindex aa3eb02..97b04a4 100644--- a/apps/rustcord/src/ui/guild_menu.rs+++ b/apps/rustcord/src/ui/guild_menu.rs@@ -22,8 +22,8 @@ const MODERATE_MEMBERS: u64 = 1 << 40;/// Discord shows Security Actions to these (any of them).pub(super) const INCIDENT_PERMS: u64 = permissions::ADMINISTRATOR | permissions::MANAGE_GUILD | BAN_MEMBERS | KICK_MEMBERS | MODERATE_MEMBERS;-/// Server mute lengths (seconds; -1 = until turned back on).-const MUTE_TIMES: [(i64, &str); 6] = [+/// Mute lengths for servers and channels (seconds; -1 = until turned back on).+pub(super) const MUTE_TIMES: [(i64, &str); 6] = [(900, "For 15 Minutes"),(3600, "For 1 Hour"),(10800, "For 3 Hours"),@@ -89,16 +89,17 @@ pub enum GuildDialog {ActiveThreads { guild: Id },}-/// A menu row; submenus open beside their row while hovered.-enum Row {- Item { glyph: Option<&'static str>, label: String, sub: Option<String>, act: GuildAct, danger: bool, enabled: bool },- Check { glyph: Option<&'static str>, label: String, on: bool, act: GuildAct },- Radio { label: String, on: bool, act: GuildAct },- Sub { glyph: Option<&'static str>, label: String, sub: Option<String>, rows: Vec<Row> },+/// A menu row (the server and channel menus share them); submenus open+/// beside their row while hovered. `sub` is a muted second line.+pub(super) enum Row<A = GuildAct> {+ Item { glyph: Option<&'static str>, label: String, sub: Option<String>, act: A, danger: bool, enabled: bool },+ Check { glyph: Option<&'static str>, label: String, on: bool, act: A },+ Radio { label: String, sub: Option<String>, on: bool, act: A },+ Sub { glyph: Option<&'static str>, label: String, sub: Option<String>, rows: Vec<Row<A>> },Sep,}-fn item(glyph: Option<&'static str>, label: &str, act: GuildAct) -> Row {+pub(super) fn item<A>(glyph: Option<&'static str>, label: &str, act: A) -> Row<A> {Row::Item { glyph, label: label.into(), sub: None, act, danger: false, enabled: true }}@@ -130,6 +131,7 @@ impl RustCord {/// Right-click on a server icon.pub fn open_guild_menu(&mut self, guild: Id, at: Pos2) {self.server_menu = None;+ self.channel_menu = None;self.guild_menu = Some((guild, at, self.ctx.cumulative_pass_nr()));self.ctx.data_mut(|d| d.remove::<Vec<usize>>(sub_path_id()));}@@ -357,6 +359,18 @@ impl RustCord {}}+ /// Move a server folder in your server list (dragged on the rail) and save the list.+ pub fn move_folder(&mut self, folder: u64, to: GuildMove) {+ match self.account_proto.move_folder(folder, to) {+ Ok(Some(patch)) => {+ self.store.folders = self.account_proto.folders();+ self.api("gm:move", Method::PATCH, "/users/@me/settings-proto/1", Some(json!({ "settings": patch })));+ }+ Ok(None) => {}+ Err(_) => self.toast("Couldn't read your server list to move this folder.", true),+ }+ }+/// "Mark as Read": every unread channel and thread of the server, in one/// bulk ack like Discord's.pub fn mark_guild_read(&mut self, g: Id) {@@ -433,6 +447,7 @@ impl RustCord {/// The dialogs opened from the server menus (called every frame).pub fn guild_dialog_ui(&mut self, ctx: &egui::Context) {self.guild_menu_ui(ctx);+ self.channel_menu_ui(ctx);for tag in ["gm:move", "gm:ack", "gm:privacy", "gm:raid", "gm:incident", "pp:save"] {match self.api_take(tag) {Some(Err(e)) => self.toast(format!("{}: {e}", failure(tag)), true),@@ -853,7 +868,7 @@ impl RustCord {// ---- drawing ----------------------------------------------------------------------------fn sub_path_id() -> egui::Id {+pub(super) fn sub_path_id() -> egui::Id {egui::Id::new("guild_menu_sub_path")}@@ -873,7 +888,7 @@ fn dialog_guild(d: &GuildDialog) -> Id {fn failure(tag: &str) -> &'static str {match tag {- "gm:move" => "Couldn't move the server",+ "gm:move" => "Couldn't save your server list","gm:ack" => "Couldn't mark the server as read","gm:privacy" => "Couldn't save the privacy setting","gm:raid" => "Couldn't report the raid",@@ -882,7 +897,7 @@ fn failure(tag: &str) -> &'static str {}}-fn level_label(level: u8) -> &'static str {+pub(super) fn level_label(level: u8) -> &'static str {match level {1 => "Only @mentions",2 => "Nothing",@@ -899,7 +914,7 @@ fn hours_label(h: u32) -> String {}/// "Muted until 21:30" (today) or "Muted until 24/11/2026, 21:30".-fn mute_until_label(end: &str) -> Option<String> {+pub(super) fn mute_until_label(end: &str) -> Option<String> {let end = chrono::DateTime::parse_from_rfc3339(end).ok()?.with_timezone(&chrono::Local);let when = if end.date_naive() == chrono::Local::now().date_naive() { end.format("%H:%M").to_string() } else { end.format("%d/%m/%Y, %H:%M").to_string() };Some(format!("Muted until {when}"))@@ -919,7 +934,7 @@ fn override_label(c: &discord::model::Channel) -> String {fn notify_rows(n: &GuildNotify, level: u8) -> Vec<Row> {let mut rows: Vec<Row> = [(0u8, "All Messages"), (1, "Only @mentions"), (2, "Nothing")].iter()- .map(|(v, l)| Row::Radio { label: (*l).into(), on: level == *v, act: GuildAct::Notify(*v) })+ .map(|(v, l)| Row::Radio { label: (*l).into(), sub: None, on: level == *v, act: GuildAct::Notify(*v) }).collect();rows.push(Row::Sep);rows.push(Row::Check { glyph: None, label: "Suppress @everyone and @here".into(), on: n.suppress_everyone, act: GuildAct::SuppressEveryone });@@ -935,7 +950,7 @@ fn notify_rows(n: &GuildNotify, level: u8) -> Vec<Row> {/// `level` is its depth; `rects` collects every menu's rect so a click/// outside all of them closes the menu.#[allow(clippy::too_many_arguments)]-fn draw_menu(ctx: &egui::Context, t: &Theme, id: egui::Id, at: Pos2, rows: &[Row], level: usize, picked: &mut Option<GuildAct>, rects: &mut Vec<Rect>) {+pub(super) fn draw_menu<A: Copy>(ctx: &egui::Context, t: &Theme, id: egui::Id, at: Pos2, rows: &[Row<A>], level: usize, picked: &mut Option<A>, rects: &mut Vec<Rect>) {let mut path: Vec<usize> = ctx.data(|d| d.get_temp(sub_path_id())).unwrap_or_default();let mut open_sub: Option<(usize, Rect)> = None;let mut hovered_row: Option<usize> = None;@@ -969,8 +984,11 @@ fn draw_menu(ctx: &egui::Context, t: &Theme, id: egui::Id, at: Pos2, rows: &[Row*picked = Some(*act);}}- Row::Radio { label, on, act } => {- let resp = super::ctx_row(ui, t, None, label, None, false, true);+ Row::Radio { label, sub, on, act } => {+ let resp = match sub {+ Some(s) => sub_row(ui, t, None, label, s, None, true),+ None => super::ctx_row(ui, t, None, label, None, false, true),+ };paint_radio(ui, t, pos2(resp.rect.right() - 18.0, resp.rect.center().y), *on);if resp.hovered() {hovered_row = Some(i);@@ -1022,7 +1040,7 @@ fn draw_menu(ctx: &egui::Context, t: &Theme, id: egui::Id, at: Pos2, rows: &[Row/// Like Discord's menus: as wide as the longest row (188-320 px), counting/// its icon and the checkbox, radio or arrow on the right.-fn menu_width(ctx: &egui::Context, rows: &[Row]) -> f32 {+fn menu_width<A>(ctx: &egui::Context, rows: &[Row<A>]) -> f32 {let text = |label: &str| ctx.fonts(|f| f.layout_no_wrap(label.to_string(), crate::style::medium(14.0), Color32::WHITE).size().x);let widest = rows.iter()diff --git a/apps/rustcord/src/ui/invite.rs b/apps/rustcord/src/ui/invite.rsindex 309b82f..13a8869 100644--- a/apps/rustcord/src/ui/invite.rs+++ b/apps/rustcord/src/ui/invite.rs@@ -169,7 +169,7 @@ impl RustCord {let place = guild.and_then(|g| self.store.guilds.get(&g)).map(|g| g.guild.name.clone())- .or_else(|| channel.as_ref().map(crate::store::Store::channel_label))+ .or_else(|| channel.as_ref().map(|c| self.store.label(c))).unwrap_or_default();let mut close = false;// Escape: an open dropdown first, then the settings view, then the modal.@@ -233,7 +233,7 @@ impl RustCord {if let Some(c) = &channel {let glyph = super::channel_icon(c.kind);p.text(pos2(lead.right() + 14.0, sub_y), Align2::CENTER_CENTER, glyph, icon_font(16.0), t.interactive_normal);- line(&p, pos2(lead.right() + 24.0, sub_y), Align2::LEFT_CENTER, &crate::store::Store::channel_label(c), FontId::proportional(16.0), t.interactive_normal, (rect.right() - PAD - lead.right() - 24.0).max(40.0));+ line(&p, pos2(lead.right() + 24.0, sub_y), Align2::LEFT_CENTER, &self.store.label(c), FontId::proportional(16.0), t.interactive_normal, (rect.right() - PAD - lead.right() - 24.0).max(40.0));}// Search.diff --git a/apps/rustcord/src/ui/members.rs b/apps/rustcord/src/ui/members.rsindex fe17895..7c88d69 100644--- a/apps/rustcord/src/ui/members.rs+++ b/apps/rustcord/src/ui/members.rs@@ -692,7 +692,7 @@ impl RustCord {let guild = ch.and_then(|c| c.guild_id).or(first.guild_id).and_then(|g| self.store.guilds.get(&g));let (title, sub) = match (ch, guild) {(Some(c), Some(g)) => (Store::channel_label(c), Some(g.guild.name.clone())),- (Some(c), None) => (Store::channel_label(c), None),+ (Some(c), None) => (self.store.label(c), None),(None, Some(g)) => ("Unknown channel".to_string(), Some(g.guild.name.clone())),(None, None) => ("Unknown channel".to_string(), None),};@@ -753,7 +753,7 @@ impl RustCord {ui.set_width(ui.available_width() - 16.0);let (row, _) = ui.allocate_exact_size(vec2(ui.available_width(), 22.0), Sense::hover());let p = ui.painter_at(row);- let name = p.text(pos2(row.left(), row.center().y), Align2::LEFT_CENTER, m.display_name(), crate::style::medium(16.0), self.name_color(m));+ let name = p.text(pos2(row.left(), row.center().y), Align2::LEFT_CENTER, self.author_name(m), crate::style::medium(16.0), self.name_color(m));p.text(pos2(name.right() + 4.0, row.center().y + 1.0), Align2::LEFT_CENTER, format_timestamp(&m.timestamp), crate::style::medium(12.0), t.text_muted);if !m.content.is_empty() {self.render_markdown_sized(ui, m, &m.content, 16.0, t.text_normal, actions);@@ -790,7 +790,7 @@ impl RustCord {ui.add_space(8.0);ui.vertical(|ui| {ui.horizontal(|ui| {- ui.label(bold(m.display_name()).size(15.0).color(t.header_primary));+ ui.label(bold(self.author_name(m)).size(15.0).color(t.header_primary));ui.label(RichText::new(format_timestamp(&m.timestamp)).size(11.5).color(t.text_muted));});if !m.content.is_empty() {diff --git a/apps/rustcord/src/ui/mod.rs b/apps/rustcord/src/ui/mod.rsindex 88e6339..68f5f5e 100644--- a/apps/rustcord/src/ui/mod.rs+++ b/apps/rustcord/src/ui/mod.rs@@ -11,6 +11,7 @@ pub mod reactions;mod expression;pub mod forum;mod friends;+pub mod friend_nickname;pub mod guild_pages;pub mod boosts;pub mod interactions;@@ -41,6 +42,7 @@ mod store;pub mod switch_accounts;pub mod moderation;pub mod guild_menu;+pub mod channel_menu;pub mod add_server;pub mod request_log;mod experimental;@@ -376,6 +378,7 @@ impl RustCord {self.soundboard_ui(ctx);self.pins_popout(ctx);self.stranger_confirm_ui(ctx);+ self.friend_nickname_ui(ctx);self.bot_modal_ui(ctx);self.threads_popout_ui(ctx);self.inbox_popout(ctx);diff --git a/apps/rustcord/src/ui/moderation.rs b/apps/rustcord/src/ui/moderation.rsindex 0c3cd35..72d8691 100644--- a/apps/rustcord/src/ui/moderation.rs+++ b/apps/rustcord/src/ui/moderation.rs@@ -111,6 +111,7 @@ enum Pick {Mention,Message,AddNote,+ FriendNickname,Volume(f32, bool),StreamVolume(f32, bool),LocalMute,@@ -620,6 +621,7 @@ impl RustCord {let name = user.username.clone();let timed_out = self.moderation.timeouts.get(&(g, uid)).is_some_and(|until| *until > now_unix());let blocked = self.store.relationships.get(&uid).is_some_and(|r| r.kind == 2);+ let nickname_row = self.friend_nickname_row(uid);let can_nick = if is_me { has(permissions::CHANGE_NICKNAME) || has(MANAGE_NICKNAMES) } else { has(MANAGE_NICKNAMES) && outranks };let can_timeout = has(MODERATE_MEMBERS) && outranks && !self.mod_is_admin(g, uid);// Voice: moderator rows while they're in one of this server's@@ -657,6 +659,9 @@ impl RustCord {if !is_me {rows.item(ui, None, "Message", false, Pick::Message);rows.item(ui, None, "Add Note", false, Pick::AddNote);+ if let Some(label) = nickname_row {+ rows.item(ui, None, label, false, Pick::FriendNickname);+ }}if in_my_call {rows.group();@@ -822,6 +827,7 @@ impl RustCord {Pick::Message => self.open_dm_with(uid, String::new()),// The full profile holds the note ("Only visible to you").Pick::AddNote => self.open_full_profile(user, Some(g)),+ Pick::FriendNickname => self.open_friend_nickname(uid),Pick::Volume(v, done) => self.set_user_volume(uid, v, done),Pick::StreamVolume(v, done) => self.set_watch_volume(v / 100.0, done),Pick::LocalMute => self.toggle_local_mute(uid),diff --git a/apps/rustcord/src/ui/popups.rs b/apps/rustcord/src/ui/popups.rsindex dc36347..37c9241 100644--- a/apps/rustcord/src/ui/popups.rs+++ b/apps/rustcord/src/ui/popups.rs@@ -3,7 +3,6 @@use super::{expression, paint_avatar};use crate::app::RustCord;use crate::features::PickerTarget;-use crate::store::Store;use crate::style::{bold, icon_font};use discord::model::{channel_kind, Id};use eframe::egui::{@@ -226,7 +225,7 @@ impl RustCord {let avatar = (c.kind == channel_kind::DM).then(|| c.recipients.first().map(|u| u.avatar_or_default(64))).flatten();- dests.push((id, Store::channel_label(c), String::new(), avatar, true));+ dests.push((id, self.store.label(c), String::new(), avatar, true));}for gid in &self.store.guild_order {let Some(g) = self.store.guilds.get(gid) else { continue };diff --git a/apps/rustcord/src/ui/profile.rs b/apps/rustcord/src/ui/profile.rsindex a475b6d..cc63e18 100644--- a/apps/rustcord/src/ui/profile.rs+++ b/apps/rustcord/src/ui/profile.rs@@ -9,7 +9,7 @@ use super::motion::{self, Motion};use super::profile_theme as theme;use super::{paint_avatar, paint_status_dot, status_label};use crate::app::RustCord;-use crate::store::{ChannelRow, Store};+use crate::store::ChannelRow;use crate::style::{bold, icon, icon_font, overlay};use discord::model::{channel_kind, Id, Message, User};use discord::settings_proto::CustomStatus;@@ -3851,7 +3851,7 @@ impl RustCord {for id in self.store.dm_list() {if let Some(c) = self.store.channels.get(&id) {let avatar = (c.kind == channel_kind::DM).then(|| c.recipients.first().map(|u| u.avatar_or_default(64))).flatten();- items.push((Store::channel_label(c), "Direct Message".into(), avatar, SwitchTo::Channel(id)));+ items.push((self.store.label(c), "Direct Message".into(), avatar, SwitchTo::Channel(id)));}}for r in self.store.relationships.values().filter(|r| r.kind == 1) {diff --git a/apps/rustcord/src/ui/reactions.rs b/apps/rustcord/src/ui/reactions.rsindex 3131ae2..2ed9703 100644--- a/apps/rustcord/src/ui/reactions.rs+++ b/apps/rustcord/src/ui/reactions.rs@@ -156,7 +156,7 @@ impl RustCord {}let av = Rect::from_center_size(pos2(row.left() + 28.0, row.center().y), vec2(24.0, 24.0));super::paint_avatar(ui, av, Some(u.avatar_or_default(64)), u.display_name());- let nick = guild.and_then(|g| self.store.members.get(&(g, u.id))).and_then(|m| m.nick.clone());+ let nick = self.store.nick_in(guild, Some(channel), u.id);let shown = nick.unwrap_or_else(|| u.display_name().to_string());let p = ui.painter_at(row.shrink2(vec2(12.0, 0.0)));let name = super::paint_text_emoji(ui, &p, pos2(av.right() + 8.0, row.center().y), &shown, crate::style::medium(16.0), t.header_primary);diff --git a/apps/rustcord/src/ui/server.rs b/apps/rustcord/src/ui/server.rsindex 28a4c63..21265e8 100644--- a/apps/rustcord/src/ui/server.rs+++ b/apps/rustcord/src/ui/server.rs@@ -393,6 +393,25 @@ impl RustCord {});done |= off;}+ ServerDialog::DeleteChannel { channel, category } => {+ let (channel, category) = (*channel, *category);+ let Some(name) = self.store.channels.get(&channel).map(crate::store::Store::channel_label) else { return };+ let (title, what) = if category { ("Delete Category", name) } else { ("Delete Channel", format!("#{name}")) };+ let off = modal(ctx, &t, title, |ui| {+ ui.label(RichText::new(format!("Are you sure you want to delete {what}? This cannot be undone.")).color(t.text_normal));+ ui.add_space(16.0);+ ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {+ if ui.add(Button::new(bold(title).color(Color32::WHITE)).fill(t.danger).rounding(6.0)).clicked() {+ self.backend.send(Command::DeleteChannel(channel));+ done = true;+ }+ if ui.button("Cancel").clicked() {+ done = true;+ }+ });+ });+ done |= off;+ }}if !done {self.server_dialog = Some(d);diff --git a/apps/rustcord/src/ui/sidebar.rs b/apps/rustcord/src/ui/sidebar.rsindex 870b58c..7ee1119 100644--- a/apps/rustcord/src/ui/sidebar.rs+++ b/apps/rustcord/src/ui/sidebar.rs@@ -1,7 +1,7 @@//! Server bar (folders, badges), channel list, Home (Friends + DMs) and the user panel.use super::{acronym, paint_avatar, paint_status_dot};-use crate::app::{ConnState, RustCord};+use crate::app::{ConnState, RailDrag, RustCord};use crate::store::{ChannelRow, Store};use crate::style::{bold, icon, icon_font, overlay, Theme};use discord::model::{channel_kind, Id};@@ -258,7 +258,7 @@ fn rail_button(ui: &mut Ui, t: &Theme, svg: &'static [u8], key: &str) -> Respons/// Collapsed folder: a tinted tile with up to four mini server icons.fn folder_tile(ui: &mut Ui, t: &Theme, color: Color32, icons: &[(Option<String>, String)], unread: bool, mentions: u32) -> Response {- let (rect, resp) = ui.allocate_exact_size(vec2(72.0, 48.0), Sense::click());+ let (rect, resp) = ui.allocate_exact_size(vec2(72.0, 48.0), Sense::click_and_drag());let tile = Rect::from_min_size(pos2(rect.center().x - 20.0, rect.top()), vec2(40.0, 40.0));super::fill_squircle(ui.painter(), tile, color.gamma_multiply(0.4));let mini_px = super::cdn_size(15.0 * ui.ctx().pixels_per_point());@@ -443,9 +443,12 @@ impl RustCord {let mut guild_menu_at: Option<(Id, egui::Pos2)> = None;// Dragging a server to move it: each icon's place, for the drop.let mut drops: Vec<(Rect, RailDrop)> = Vec::new();- let mut drag_start: Option<Id> = None;- // No tooltips while a server is being dragged.- let dragging = self.guild_drag.is_some();+ // Each folder's rows and what it looks like there (its tile, or the open+ // folder's background), for dragging a folder.+ let mut spans: Vec<(Rect, Rect, u64)> = Vec::new();+ let mut drag_start: Option<RailDrag> = None;+ // No tooltips while a server or folder is being dragged.+ let dragging = self.rail_drag.is_some();// Layout: folders from settings-proto if we have them, else READY order.let mut layout: Vec<(Option<u64>, Option<String>, Option<u32>, Vec<Id>)> = self@@ -467,9 +470,11 @@ impl RustCord {// Icons that carry a mention badge (for Discord's red "NEW" pill when// one is scrolled out of view).let mut mention_rects: Vec<Rect> = Vec::new();+ // No drag-to-scroll (Discord's rail has none): a drag moves a server or folder.let scroll = ScrollArea::vertical().scroll_bar_visibility(ScrollBarVisibility::AlwaysHidden).auto_shrink([false, false])+ .drag_to_scroll(false).max_height(list_h).show(ui, |ui| {ui.spacing_mut().item_spacing.y = 0.0;@@ -496,7 +501,7 @@ impl RustCord {// DMs with unread mentions, newest first, each with its count.for id in self.store.dm_list().into_iter().filter(|c| self.store.mentions(*c) > 0) {let Some(c) = self.store.channels.get(&id) else { continue };- let name = Store::channel_label(c);+ let name = self.store.label(c);let r = server_icon(ui,&t,@@ -566,7 +571,7 @@ impl RustCord {let r = r.interact(Sense::drag());drops.push((r.rect, RailDrop::Server(*g)));if drag_began(ui, &r) {- drag_start = Some(*g);+ drag_start = Some(RailDrag::Server(*g));}let rows = if r.hovered() { voice_tip_rows(&self.store, *g) } else { Vec::new() };let r = if dragging { r } else { rail_tip_rows(r, &t, &gname, &rows) };@@ -589,14 +594,18 @@ impl RustCord {let mentions: u32 = ids.iter().map(|g| self.store.guild_mentions(*g)).sum();if expanded {let top = ui.cursor().top();- let (rect, r) = ui.allocate_exact_size(vec2(72.0, 48.0), Sense::click());+ let (rect, r) = ui.allocate_exact_size(vec2(72.0, 48.0), Sense::click_and_drag());let header = Rect::from_min_size(pos2(rect.center().x - 20.0, rect.top()), vec2(40.0, 40.0));let bg_idx = ui.painter().add(egui::Shape::Noop);ui.painter().text(header.center(), Align2::CENTER_CENTER, icon::FOLDER, icon_font(22.0), fcolor);if let Some(first) = ids.first() {drops.push((r.rect, RailDrop::FolderHeader(fid, *first)));}- if rail_tip(r, &t, &fname).clicked() {+ if drag_began(ui, &r) {+ drag_start = Some(RailDrag::Folder(fid));+ }+ let r = if dragging { r } else { rail_tip(r, &t, &fname) };+ if r.clicked() {toggle_folder = Some(fid);}for g in ids {@@ -619,7 +628,7 @@ impl RustCord {let r = r.interact(Sense::drag());drops.push((r.rect, RailDrop::Server(*g)));if drag_began(ui, &r) {- drag_start = Some(*g);+ drag_start = Some(RailDrag::Server(*g));}let rows = if r.hovered() { voice_tip_rows(&self.store, *g) } else { Vec::new() };let r = if dragging { r } else { rail_tip_rows(r, &t, &gname, &rows) };@@ -634,6 +643,7 @@ impl RustCord {// Icons are flush with each row's top, 8 px gap below.let bg = Rect::from_min_max(pos2(rect.center().x - 24.0, top - 4.0), pos2(rect.center().x + 24.0, bottom - 4.0));ui.painter().set(bg_idx, egui::Shape::rect_filled(bg, 16.0, fcolor.gamma_multiply(0.18)));+ spans.push((Rect::from_x_y_ranges(rect.x_range(), top..=bottom), bg, fid));} else {let icons: Vec<_> = ids.iter().map(|g| icon_for(&self.store, *g)).collect();let r = folder_tile(ui, &t, fcolor, &icons, unread, mentions);@@ -641,7 +651,12 @@ impl RustCord {mention_rects.push(r.rect);}drops.push((r.rect, RailDrop::Folder(fid)));- if rail_tip(r, &t, &fname).clicked() {+ spans.push((r.rect, Rect::from_min_size(pos2(r.rect.center().x - 20.0, r.rect.top()), vec2(40.0, 40.0)), fid));+ if drag_began(ui, &r) {+ drag_start = Some(RailDrag::Folder(fid));+ }+ let r = if dragging { r } else { rail_tip(r, &t, &fname) };+ if r.clicked() {toggle_folder = Some(fid);}}@@ -682,10 +697,10 @@ impl RustCord {jump = Some(y - view.center().y + 20.0);}}- if let Some(g) = drag_start.filter(|_| self.guild_drag.is_none()) {- self.guild_drag = Some(g);+ if let Some(d) = drag_start.filter(|_| self.rail_drag.is_none()) {+ self.rail_drag = Some(d);}- if let Some(dy) = self.guild_drag_ui(ui, &drops, view, &t) {+ if let Some(dy) = self.rail_drag_ui(ui, &drops, &spans, view, &t) {jump = Some(jump.unwrap_or(0.0) + dy);}if let Some(dy) = jump {@@ -714,33 +729,43 @@ impl RustCord {}}- /// While a server is dragged on the rail: its icon follows the pointer, a line shows- /// where it lands (or the folder it drops into lights up), and releasing it saves the- /// new order to your account. Esc or a release off the rail cancels. Returns how far to- /// scroll the rail when the pointer is held near its top or bottom edge.- fn guild_drag_ui(&mut self, ui: &mut Ui, drops: &[(Rect, RailDrop)], view: Rect, t: &Theme) -> Option<f32> {+ /// While a server or folder is dragged on the rail: it follows the pointer, a line+ /// shows where it lands (or the folder a server drops into lights up), and releasing+ /// it saves the new order to your account. Esc or a release off the rail cancels.+ /// Returns how far to scroll the rail when the pointer is held near its top or+ /// bottom edge.+ fn rail_drag_ui(&mut self, ui: &mut Ui, drops: &[(Rect, RailDrop)], spans: &[(Rect, Rect, u64)], view: Rect, t: &Theme) -> Option<f32> {use discord::settings_proto::GuildMove;- let dragged = self.guild_drag?;- let Some(guild) = self.store.guilds.get(&dragged) else {- self.guild_drag = None;+ let dragged = self.rail_drag?;+ // What follows the pointer: the server's icon, or the folder's tile.+ let ghost = match dragged {+ RailDrag::Server(g) => self.store.guilds.get(&g).map(|gs| {+ let url = gs.guild.icon_url(super::cdn_size(40.0 * ui.ctx().pixels_per_point()));+ (url, acronym(&gs.guild.name), None)+ }),+ RailDrag::Folder(f) => self.store.folders.iter().find(|x| x.id == Some(f)).map(|x| {+ let color = x.color.map(|c| Color32::from_rgb((c >> 16) as u8, (c >> 8) as u8, c as u8)).unwrap_or(t.accent);+ (None, String::new(), Some(color))+ }),+ };+ let Some((url, label, folder_color)) = ghost else {+ self.rail_drag = None;return None;};- let (url, name) = (guild.guild.icon_url(super::cdn_size(40.0 * ui.ctx().pixels_per_point())), guild.guild.name.clone());let (pos, down, escape) = ui.input(|i| (i.pointer.latest_pos(), i.pointer.primary_down(), i.key_pressed(egui::Key::Escape)));let Some(pos) = pos.filter(|_| !escape) else {- self.guild_drag = None;+ self.rail_drag = None;return None;};ui.ctx().request_repaint();- // The landing place: the row under the pointer, above or below its middle.+ // The landing place: the row under the pointer, above or below its middle, as+ // (what to mark, the move).let on_rail = (view.left() - 24.0..=view.right() + 24.0).contains(&pos.x) && view.contains(pos2(view.center().x, pos.y));- let target = drops- .iter()- .filter(|_| on_rail)- .find(|(r, _)| (r.top()..r.bottom()).contains(&pos.y))- .map(|&(r, drop)| {+ let icon_of = |r: Rect| Rect::from_min_size(pos2(r.center().x - 20.0, r.top()), vec2(40.0, 40.0));+ let target: Option<(Rect, Option<GuildMove>)> = match dragged {+ _ if !on_rail => None,+ RailDrag::Server(dragged) => drops.iter().find(|(r, _)| (r.top()..r.bottom()).contains(&pos.y)).map(|&(r, drop)| {let upper = pos.y < r.top() + 20.0;- let icon = Rect::from_min_size(pos2(r.center().x - 20.0, r.top()), vec2(40.0, 40.0));let mv = match drop {RailDrop::Server(g) if g == dragged => None,RailDrop::Server(g) => Some(if upper { GuildMove::Before(g) } else { GuildMove::After(g) }),@@ -751,24 +776,37 @@ impl RustCord {RailDrop::FolderHeader(_, first) if first == dragged => None,RailDrop::FolderHeader(_, first) => Some(GuildMove::Before(first)),};- (icon, mv)- });+ (icon_of(r), mv)+ }),+ // A folder lands between folders and loose servers, never inside a folder.+ RailDrag::Folder(dragged) => match spans.iter().find(|(r, _, _)| (r.top()..r.bottom()).contains(&pos.y)) {+ Some(&(r, look, f)) => {+ let upper = pos.y < r.center().y;+ let mv = (f != dragged).then_some(if upper { GuildMove::BeforeFolder(f) } else { GuildMove::AfterFolder(f) });+ Some((Rect::from_center_size(look.center(), vec2(40.0, look.height())), mv))+ }+ None => drops.iter().find(|(r, _)| (r.top()..r.bottom()).contains(&pos.y)).and_then(|&(r, drop)| match drop {+ RailDrop::Server(g) => Some((icon_of(r), Some(if pos.y < r.top() + 20.0 { GuildMove::Before(g) } else { GuildMove::After(g) }))),+ _ => None,+ }),+ },+ };let layer = ui.ctx().layer_painter(egui::LayerId::new(egui::Order::Tooltip, egui::Id::new("guild_drag_layer")));- if let Some((icon, Some(mv))) = target {- let line = |y: f32| Rect::from_center_size(pos2(icon.center().x, y), vec2(40.0, 4.0));+ if let Some((mark, Some(mv))) = target {+ let line = |y: f32| Rect::from_center_size(pos2(mark.center().x, y), vec2(40.0, 4.0));match mv {GuildMove::Folder(_) => {- layer.rect_stroke(icon.expand(4.0), 16.0, Stroke::new(2.0_f32, t.accent));+ layer.rect_stroke(mark.expand(4.0), 16.0, Stroke::new(2.0_f32, t.accent));}GuildMove::Before(_) | GuildMove::BeforeFolder(_) => {- layer.rect_filled(line(icon.top() - 4.0), 2.0, t.accent);+ layer.rect_filled(line(mark.top() - 4.0), 2.0, t.accent);}_ => {- layer.rect_filled(line(icon.bottom() + 4.0), 2.0, t.accent);+ layer.rect_filled(line(mark.bottom() + 4.0), 2.0, t.accent);}}}- // The dragged server, under the pointer.+ // The dragged server or folder, under the pointer.let ghost = Rect::from_center_size(pos, vec2(40.0, 40.0));egui::Area::new(egui::Id::new("guild_drag_ghost")).order(egui::Order::Tooltip)@@ -777,15 +815,21 @@ impl RustCord {.show(ui.ctx(), |ui| {ui.set_opacity(0.8);let (rect, _) = ui.allocate_exact_size(vec2(40.0, 40.0), Sense::hover());- if !url.as_deref().is_some_and(|url| super::paint_squircle_image(ui, rect, url)) {+ if let Some(color) = folder_color {+ super::fill_squircle(ui.painter(), rect, color.gamma_multiply(0.4));+ ui.painter().text(rect.center(), Align2::CENTER_CENTER, icon::FOLDER, icon_font(22.0), color);+ } else if !url.as_deref().is_some_and(|url| super::paint_squircle_image(ui, rect, url)) {super::fill_squircle(ui.painter(), rect, t.accent);- ui.painter().text(rect.center(), Align2::CENTER_CENTER, acronym(&name), crate::style::medium(16.0), Color32::WHITE);+ ui.painter().text(rect.center(), Align2::CENTER_CENTER, label, crate::style::medium(16.0), Color32::WHITE);}});if !down {- self.guild_drag = None;+ self.rail_drag = None;if let Some((_, Some(mv))) = target {- self.move_guild(dragged, mv);+ match dragged {+ RailDrag::Server(g) => self.move_guild(g, mv),+ RailDrag::Folder(f) => self.move_folder(f, mv),+ }}return None;}@@ -1028,7 +1072,7 @@ impl RustCord {let mut toggle = None;let row = |this: &Self, ui: &mut Ui, f: &discord::settings_proto::Favorite, select: &mut Option<Id>| {let Some(c) = this.store.channels.get(&f.id) else { return };- let name = f.nickname.clone().unwrap_or_else(|| Store::channel_label(c));+ let name = f.nickname.clone().unwrap_or_else(|| this.store.label(c));let glyph = super::channel_icon(c.kind);let selected = this.current_channel == Some(f.id);let unread = this.store.is_unread(f.id);@@ -1230,6 +1274,7 @@ impl RustCord {let mut stream_hover: Option<(Id, Id, egui::Pos2)> = None;let mut watch_stream: Option<(Id, Id)> = None;let mut join_voice: Option<Id> = None;+ let mut channel_menu: Option<(Id, egui::Pos2)> = None;// Names for people in voice we haven't seen yet (op 8).let unknown = self.store.unknown_voice_members(gid);if !unknown.is_empty() {@@ -1337,6 +1382,9 @@ impl RustCord {if out.resp.hovered() && !selected {hovered_channel = Some(*id);}+ if out.resp.secondary_clicked() {+ channel_menu = out.resp.interact_pointer_pos().map(|p| (*id, p));+ }if out.invite {invite = Some(*id);} else if out.edit {@@ -1439,6 +1487,9 @@ impl RustCord {if let Some(id) = join_voice {self.join_voice(id);}+ if let Some((id, at)) = channel_menu {+ self.open_channel_menu(id, at);+ }self.channel_drag_ui(ui, gid, &targets, t);if let Some(id) = select {// Picking a channel leaves Members / Server Boosts / Server Shop.@@ -1539,7 +1590,7 @@ impl RustCord {for id in order {let is_pinned = pinned.contains(&id);let Some(c) = self.store.channels.get(&id) else { continue };- let name = Store::channel_label(c);+ let name = self.store.label(c);let recipient = (c.kind == channel_kind::DM).then(|| c.recipients.first()).flatten();// A group's own picture when it has one (else its initial).let group_icon = c.icon.as_ref().filter(|_| recipient.is_none()).map(|h| format!("https://cdn.discordapp.com/channel-icons/{}/{h}.png?size=64", id.0));@@ -1662,6 +1713,7 @@ impl RustCord {let person = self.store.channels.get(&id).filter(|c| c.kind == channel_kind::DM).and_then(|c| c.recipients.first().cloned());let unread = self.store.is_unread(id);let last_msg = self.store.channels.get(&id).and_then(|c| c.last_message_id);+ let nickname_row = person.as_ref().and_then(|u| self.friend_nickname_row(u.id));let mut pick: Option<u8> = None;let area = egui::Area::new(egui::Id::new("dm_menu")).order(egui::Order::Foreground).fixed_pos(at).constrain(true).show(ui.ctx(), |ui| {// Discord's DM menu (2026-11-22): "Mark As Read" alone, then Pin,@@ -1688,6 +1740,9 @@ impl RustCord {row(ui, None, "Profile", true, 2);}row(ui, None, "Call", true, 3);+ if let Some(label) = nickname_row {+ row(ui, None, label, true, 7);+ }row(ui, None, "Close DM", true, 4);super::ctx_separator(ui, t);row(ui, Some(icon::ID), "Copy Channel ID", true, 5);@@ -1723,6 +1778,11 @@ impl RustCord {}}Some(3) => self.start_dm_call(id),+ Some(7) => {+ if let Some(user) = &person {+ self.open_friend_nickname(user.id);+ }+ }Some(4) => close_dm = Some((id, self.current_channel == Some(id) && !self.friends_open)),Some(5) => ui.ctx().copy_text(id.to_string()),_ => {}diff --git a/apps/rustcord/src/ui/voice_menu.rs b/apps/rustcord/src/ui/voice_menu.rsindex 711dce3..cd258e8 100644--- a/apps/rustcord/src/ui/voice_menu.rs+++ b/apps/rustcord/src/ui/voice_menu.rs@@ -786,33 +786,11 @@ impl RustCord {close = true;}Act::MuteChannel(ch, until) => {- if let Some(g) = self.store.channels.get(&ch).and_then(|c| c.guild_id) {- let over = match until {- None => {- self.store.muted_channels.remove(&ch);- serde_json::json!({ "muted": false })- }- Some(secs) => {- self.store.muted_channels.insert(ch);- let end = (secs > 0).then(|| (chrono::Utc::now() + chrono::Duration::seconds(secs)).to_rfc3339_opts(chrono::SecondsFormat::Millis, true));- serde_json::json!({ "muted": true, "mute_config": { "selected_time_window": secs, "end_time": end } })- }- };- let patch = serde_json::json!({ "channel_overrides": { ch.to_string(): over } });- self.backend.send(crate::backend::Command::GuildSettings { guild: g, patch });- }+ self.mute_channel(ch, until);close = true;}Act::ChannelNotify(ch, n) => {- if let Some(g) = self.store.channels.get(&ch).and_then(|c| c.guild_id) {- if n == 3 {- self.store.channel_notify.remove(&ch);- } else {- self.store.channel_notify.insert(ch, n);- }- let patch = serde_json::json!({ "channel_overrides": { ch.to_string(): { "message_notifications": n } } });- self.backend.send(crate::backend::Command::GuildSettings { guild: g, patch });- }+ self.set_channel_notify(ch, n);close = true;}}diff --git a/crates/discord/src/fingerprint.rs b/crates/discord/src/fingerprint.rsindex b360626..12b87fb 100644--- a/crates/discord/src/fingerprint.rs+++ b/crates/discord/src/fingerprint.rs@@ -13,10 +13,12 @@//! What this is not: a disguise. It names the client the way the web client//! names itself and nothing more. The web client's integrity fields//! (`has_client_mods`, `launch_signature`, its launch ID) and its telemetry-//! are deliberately not imitated, and the connection itself (TLS and HTTP/2-//! as Windows makes them, not as Chrome does) is RustCord's own, so Discord-//! can tell RustCord from its own client if it looks. Keep it that way: the-//! values below are read from the live web client, never invented.+//! (the analytics `client_heartbeat_session_id`, and `client_app_state`:+//! whether the window is focused) are deliberately not imitated, and the+//! connection itself (TLS and HTTP/2 as Windows makes them, not as Chrome+//! does) is RustCord's own, so Discord can tell RustCord from its own client+//! if it looks. Keep it that way: the values below are read from the live+//! web client, never invented.//!//! A stale identity stands out too: Discord ships a new web build every day//! or two, and a client still claiming last month's build is a custom one.@@ -35,13 +37,16 @@ const CHROME_MAJOR: u32 = 156;/// Safari version advertised on macOS.const SAFARI_VERSION: &str = "18.5";/// Build number of the official web client when no newer one has been-/// looked up (the stable web client's on 2026-11-22).-pub const CLIENT_BUILD_NUMBER: u64 = 678_976;+/// looked up (the stable web client's on 2026-12-03).+pub const CLIENT_BUILD_NUMBER: u64 = 685_495;/// What IDENTIFY says this client can read (`capabilities`), as the web/// client sends it (2026-11-27). What each bit asks for, and what RustCord/// does with it, is listed in [`crate::gateway`].pub const CAPABILITIES: u64 = 1_767_421;pub const LOCALE: &str = "en-US";+/// `X-Debug-Options`: the web client's developer options that are on, and+/// out of the box that is only the bug reporter (2026-12-03).+pub const DEBUG_OPTIONS: &str = "bugReporterEnabled";pub const ACCEPT_LANGUAGE: &str = "en-US,en;q=0.9";/// Newer values found at startup (0: use the constants).@@ -241,9 +246,9 @@ mod tests {let html = r#"<script src="/assets/fast-connect.2acbe61f.js"></script><script defer src="/assets/sentry.f0c1db4720a1a128.js"></script>"#;assert_eq!(asset_path(html, "sentry."), Some("/assets/sentry.f0c1db4720a1a128.js"));assert_eq!(asset_path(r#"src="/assets/sentry.x.js?a=<b>""#, "sentry."), None);- let js = r#"allowUrls:[/discord\.com/]}),a.NA("buildNumber","681625"),a.NA("builtAt","1795681177399")"#;- assert_eq!(build_number_in(js), Some(681_625));- assert!(plausible_build(681_625));+ let js = r#"allowUrls:[/discord\.com/,/betterdiscord:\/\//]}),a.NA("buildNumber","685495"),a.NA("builtAt",String("1796285950288"#;+ assert_eq!(build_number_in(js), Some(685_495));+ assert!(plausible_build(CLIENT_BUILD_NUMBER + 1));assert!(!plausible_build(1) && !plausible_build(u64::MAX));}diff --git a/crates/discord/src/http.rs b/crates/discord/src/http.rsindex bd02f4f..b9273f7 100644--- a/crates/discord/src/http.rs+++ b/crates/discord/src/http.rs@@ -294,6 +294,7 @@ fn discord_headers() -> reqwest::header::HeaderMap {put("x-super-properties", crate::fingerprint::super_properties());put("x-discord-locale", crate::fingerprint::LOCALE.into());put("x-discord-timezone", crate::fingerprint::TIMEZONE.into());+ put("x-debug-options", crate::fingerprint::DEBUG_OPTIONS.into());put("accept-language", crate::fingerprint::ACCEPT_LANGUAGE.into());put("origin", "https://discord.com".into());put("referer", "https://discord.com/channels/@me".into());diff --git a/crates/discord/src/settings_proto.rs b/crates/discord/src/settings_proto.rsindex 4229918..b530b09 100644--- a/crates/discord/src/settings_proto.rs+++ b/crates/discord/src/settings_proto.rs@@ -87,9 +87,13 @@ pub struct UserSettings {}impl UserSettings {- /// For tests / demo data (no raw status bytes to preserve).+ /// For tests / demo data (no raw status bytes to preserve). The server list is+ /// stored raw as well, so it can be rearranged.pub fn new(folders: Vec<Folder>, status: &str, custom_status: Option<CustomStatus>) -> Self {- Self { version: 0, folders, favorites: Favorites::default(), status: status.to_string(), custom_status, status_wire: Vec::new(), ..Default::default() }+ let mut wire = Vec::new();+ message(14, &folders.iter().flat_map(encode_folder).collect::<Vec<u8>>(), &mut wire);+ let raw = RawSettings::from_wire(&wire).unwrap_or_default();+ Self { version: 0, folders, favorites: Favorites::default(), status: status.to_string(), custom_status, status_wire: Vec::new(), raw, ..Default::default() }}}@@ -221,6 +225,29 @@ fn string_value(bytes: &[u8]) -> Result<String, DecodeError> {// ---- decode -----------------------------------------------------------------+/// A server-list entry (field 1 of the list) for `f`, as [`decode_folder`] reads it.+fn encode_folder(f: &Folder) -> Vec<u8> {+ let wrapped = |n: u64| {+ let mut w = vec![1 << 3];+ write_varint(n, &mut w);+ w+ };+ let mut body = Vec::new();+ message(1, &f.guild_ids.iter().flat_map(|g| g.0.to_le_bytes()).collect::<Vec<u8>>(), &mut body);+ if let Some(id) = f.id {+ message(2, &wrapped(id), &mut body);+ }+ if let Some(name) = &f.name {+ string_field(3, name, &mut body);+ }+ if let Some(color) = f.color {+ message(4, &wrapped(u64::from(color)), &mut body);+ }+ let mut out = Vec::new();+ message(1, &body, &mut out);+ out+}+fn decode_folder(bytes: &[u8]) -> Result<Folder, DecodeError> {let mut folder = Folder::default();for f in fields(bytes)? {@@ -738,18 +765,11 @@ impl RawSettings {if matches!(to, GuildMove::Before(target) | GuildMove::After(target) if target == guild) {return Ok(None);}- let old = self.sections.get(&14).map_or(&[][..], Vec::as_slice);- // Each entry of the list: its folder id and servers, and its raw bytes.- let mut entries: Vec<(Folder, Vec<u8>)> = Vec::new();- let mut rest = Vec::new();- for f in fields(old)? {- if f.number != 1 {- rest.extend_from_slice(f.raw);- continue;- }- let folder = decode_folder(f.message()?)?;+ let (list, rest) = server_list(self.sections.get(&14).map_or(&[][..], Vec::as_slice))?;+ let mut entries: Vec<ListEntry> = Vec::new();+ for (folder, raw) in list {if !folder.guild_ids.contains(&guild) {- entries.push((folder, f.raw.to_vec()));+ entries.push((folder, raw));continue;}let ids: Vec<Id> = folder.guild_ids.iter().copied().filter(|g| *g != guild).collect();@@ -757,7 +777,7 @@ impl RawSettings {// A loose server, or a folder holding only this server, goes with it.continue;}- let raw = with_guilds(f.raw, &ids)?;+ let raw = with_guilds(&raw, &ids)?;entries.push((Folder { guild_ids: ids, ..folder }, raw));}let loose = || {@@ -767,7 +787,7 @@ impl RawSettings {message(1, &body, &mut raw);(Folder { id: None, name: None, color: None, guild_ids: vec![guild] }, raw)};- let folder_at = |entries: &[(Folder, Vec<u8>)], id: u64| entries.iter().position(|(f, _)| f.id == Some(id));+ let folder_at = |entries: &[ListEntry], id: u64| entries.iter().position(|(f, _)| f.id == Some(id));match to {GuildMove::First => entries.insert(0, loose()),GuildMove::Last => entries.push(loose()),@@ -799,15 +819,48 @@ impl RawSettings {}}}+ Ok(self.store_server_list(entries, &rest))+ }++ /// Move a folder in the server list (dragged on the rail): next to a loose server or+ /// next to another folder (`Before` / `After` a server in a folder means next to that+ /// folder), first or last. Folders don't nest, so `GuildMove::Folder` changes nothing.+ /// Every other byte of the server list is kept. Returns the patch for+ /// `PATCH /users/@me/settings-proto/1`, or `None` when nothing changes.+ pub fn move_folder(&mut self, folder: u64, to: GuildMove) -> Result<Option<String>, DecodeError> {+ let (mut entries, rest) = server_list(self.sections.get(&14).map_or(&[][..], Vec::as_slice))?;+ let Some(from) = entries.iter().position(|(f, _)| f.id == Some(folder)) else { return Ok(None) };+ let moved = entries.remove(from);+ let after = usize::from(matches!(to, GuildMove::After(_) | GuildMove::AfterFolder(_)));+ let at = match to {+ GuildMove::First => Some(0),+ GuildMove::Last => Some(entries.len()),+ GuildMove::Folder(_) => None,+ GuildMove::BeforeFolder(id) | GuildMove::AfterFolder(id) => entries.iter().position(|(f, _)| f.id == Some(id)).map(|at| at + after),+ GuildMove::Before(g) | GuildMove::After(g) => match entries.iter().position(|(f, _)| f.guild_ids.contains(&g)) {+ Some(at) => Some(at + after),+ // A newly joined server, shown above the stored list.+ None if moved.0.guild_ids.contains(&g) => None,+ None => Some(0),+ },+ };+ let Some(at) = at else { return Ok(None) };+ entries.insert(at, moved);+ Ok(self.store_server_list(entries, &rest))+ }++ /// Put the server list back together from its entries (and the bytes that aren't+ /// entries); the patch when it changed.+ fn store_server_list(&mut self, entries: Vec<ListEntry>, rest: &[u8]) -> Option<String> {let mut body: Vec<u8> = entries.into_iter().flat_map(|(_, raw)| raw).collect();- body.extend_from_slice(&rest);- if body == old {- return Ok(None);+ body.extend_from_slice(rest);+ if self.sections.get(&14).map_or(&[][..], Vec::as_slice) == body.as_slice() {+ return None;}let mut patch = Vec::new();message(14, &body, &mut patch);self.sections.insert(14, body);- Ok(Some(STANDARD.encode(patch)))+ Some(STANDARD.encode(patch))}/// The server list (folders and loose servers) as stored now.@@ -835,6 +888,23 @@ pub enum GuildMove {After(Id),}+/// A server-list entry: a folder (or loose server), decoded, and its raw bytes.+type ListEntry = (Folder, Vec<u8>);++/// The server list's entries and the list's other bytes.+fn server_list(body: &[u8]) -> Result<(Vec<ListEntry>, Vec<u8>), DecodeError> {+ let mut entries = Vec::new();+ let mut rest = Vec::new();+ for f in fields(body)? {+ if f.number == 1 {+ entries.push((decode_folder(f.message()?)?, f.raw.to_vec()));+ } else {+ rest.extend_from_slice(f.raw);+ }+ }+ Ok((entries, rest))+}+/// One server-list entry (`raw`: field 1 of the list, a folder) with its servers replaced/// by `ids`, keeping the folder's other fields (id, name, colour).fn with_guilds(raw: &[u8], ids: &[Id]) -> Result<Vec<u8>, DecodeError> {@@ -941,6 +1011,36 @@ mod move_tests {assert_eq!(ids(&s), vec![(None, vec![4]), (None, vec![2]), (None, vec![1]), (None, vec![3])]);assert_eq!(s.sections.get(&11).cloned(), section11);}++ #[test]+ fn demo_server_list_round_trips() {+ let f = Folder { id: Some(1), name: Some("Rust Stuff".into()), color: Some(0xE8590C), guild_ids: vec![Id(5), Id(6)] };+ let loose = Folder { guild_ids: vec![Id(7)], ..Default::default() };+ let s = UserSettings::new(vec![loose.clone(), f.clone()], "online", None);+ assert_eq!(s.raw.folders(), vec![loose, f]);+ }++ #[test]+ fn drags_folders() {+ let mut s = settings(&[folder(&[1], None, None), folder(&[3, 4], Some(9), Some("F")), folder(&[5], Some(8), Some("G")), folder(&[2], None, None)]);+ let section11 = s.sections.get(&11).cloned();+ s.move_folder(9, GuildMove::After(Id(2))).unwrap();+ assert_eq!(ids(&s), vec![(None, vec![1]), (Some(8), vec![5]), (None, vec![2]), (Some(9), vec![3, 4])]);+ assert_eq!(s.folders()[3].name.as_deref(), Some("F"));+ s.move_folder(9, GuildMove::BeforeFolder(8)).unwrap();+ assert_eq!(ids(&s), vec![(None, vec![1]), (Some(9), vec![3, 4]), (Some(8), vec![5]), (None, vec![2])]);+ // Next to a server in another folder: next to that folder.+ s.move_folder(8, GuildMove::Before(Id(4))).unwrap();+ assert_eq!(ids(&s), vec![(None, vec![1]), (Some(8), vec![5]), (Some(9), vec![3, 4]), (None, vec![2])]);+ s.move_folder(9, GuildMove::First).unwrap();+ assert_eq!(ids(&s)[0], (Some(9), vec![3, 4]));+ // No change, a folder into a folder, onto itself, or an unknown folder: no patch.+ assert!(s.move_folder(9, GuildMove::Before(Id(1))).unwrap().is_none());+ assert!(s.move_folder(9, GuildMove::Folder(8)).unwrap().is_none());+ assert!(s.move_folder(9, GuildMove::After(Id(3))).unwrap().is_none());+ assert!(s.move_folder(7, GuildMove::Last).unwrap().is_none());+ assert_eq!(s.sections.get(&11).cloned(), section11);+ }}#[cfg(test)]diff --git a/crates/vendor/epaint/src/text/font.rs b/crates/vendor/epaint/src/text/font.rsindex f538bd8..62de466 100644--- a/crates/vendor/epaint/src/text/font.rs+++ b/crates/vendor/epaint/src/text/font.rs@@ -83,9 +83,14 @@ pub struct FontImpl {/// RustCord: an icon font, drawn without LCD antialiasing (see `UvRect::gray`).gray: bool,+ /// RustCord: the font's bytes and pixels per em for its own hinting.+ hinting: Option<(&'static [u8], u32, f32)>,+/// RustCord: the font's own hinting at this size, if it has any (see- /// `super::hinted`): glyphs are then drawn from the hinted outlines.- hinted: Option<super::hinted::Hinted>,+ /// `super::hinted`): glyphs are then drawn from the hinted outlines. Made+ /// on the first glyph drawn, so the many fallback fonts that never draw+ /// one at a size (other scripts, symbols) cost nothing there.+ hinted: std::sync::OnceLock<Option<super::hinted::Hinted>>,height_in_points: f32,@@ -144,9 +149,7 @@ impl FontImpl {};// (Not for icons: their shapes aren't letters to be fitted to a grid.)- let hinted = hinting- .filter(|_| !gray)- .and_then(|(bytes, index, pixels_per_em)| super::hinted::Hinted::new(bytes, index, pixels_per_em));+ let hinting = hinting.filter(|_| !gray);Self {name,@@ -154,7 +157,8 @@ impl FontImpl {scale_in_pixels,kern_cache: Default::default(),gray,- hinted,+ hinting,+ hinted: std::sync::OnceLock::new(),height_in_points: ascent - descent + line_gap,y_offset_in_points,ascent: ascent + baseline_offset,@@ -336,6 +340,7 @@ impl FontImpl {// from the plain outline.let raster = self.hinted+ .get_or_init(|| self.hinting.and_then(|(bytes, index, pixels_per_em)| super::hinted::Hinted::new(bytes, index, pixels_per_em))).as_ref().and_then(|h| h.raster(glyph_id.0, 3.0)).or_else(|| {