Skip to content

Commit 5ff2416

Browse files
committed
feat: base private channels impl in client, update to new egui
1 parent 950701d commit 5ff2416

17 files changed

+318
-179
lines changed

Cargo.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/src/channel.rs

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,51 @@
1-
use indexmap::IndexSet;
2-
31
use crate::role::RolePerms;
42

5-
use super::message::Messages;
3+
use super::message::{Messages, PinnedMessages};
64
use harmony_rust_sdk::api::chat::{permission::has_permission, Permission};
5+
use indexmap::IndexSet;
76
use smol_str::SmolStr;
87

98
#[derive(Default, Debug, Clone)]
109
pub struct Channel {
1110
pub name: SmolStr,
1211
pub is_category: bool,
1312
pub messages: Messages,
14-
pub pinned_messages: IndexSet<u64>,
13+
pub pinned_messages: PinnedMessages,
1514
pub reached_top: bool,
1615
pub perms: Vec<Permission>,
1716
pub role_perms: RolePerms,
1817
pub fetched_msgs_pins: bool,
18+
pub private_channel_data: Option<PrivateChannel>,
1919
}
2020

2121
impl Channel {
2222
pub fn has_perm(&self, query: &str) -> bool {
2323
has_permission(self.perms.iter().map(|p| (p.matches.as_str(), p.ok)), query).unwrap_or(false)
2424
}
25+
26+
pub fn get_priv_mut(&mut self) -> &mut PrivateChannel {
27+
if self.private_channel_data.is_none() {
28+
self.private_channel_data = Some(PrivateChannel::default());
29+
}
30+
self.private_channel_data.as_mut().unwrap()
31+
}
32+
33+
/// Get the private channel data.
34+
///
35+
/// # Panics
36+
/// Panics if this is not a private channel.
37+
pub fn get_priv(&self) -> &PrivateChannel {
38+
self.private_channel_data
39+
.as_ref()
40+
.expect("not private channel -- this is a bug")
41+
}
42+
}
43+
44+
#[derive(Default, Debug, Clone)]
45+
pub struct PrivateChannel {
46+
pub server_id: Option<String>,
47+
pub members: IndexSet<u64, ahash::RandomState>,
48+
pub owner: u64,
49+
pub is_dm: bool,
50+
pub fetched: bool,
2551
}

client/src/guild.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub struct Guild {
1616
pub roles: Roles,
1717
pub role_perms: RolePerms,
1818
pub members: AHashMap<u64, Vec<u64>>,
19-
pub homeserver: SmolStr,
19+
pub homeserver: Option<String>,
2020
pub perms: Vec<Permission>,
2121
pub invites: AHashMap<String, Invite>,
2222
pub fetched: bool,

0 commit comments

Comments
 (0)