This commit is contained in:
Max Brunsfeld 2021-08-06 14:47:18 -07:00
parent 4a32bd6bb0
commit ff822c9158
4 changed files with 45 additions and 7 deletions

View File

@ -513,13 +513,18 @@ async fn test_basic_chat(mut cx_a: TestAppContext, cx_b: TestAppContext) {
)
.await
.unwrap();
assert_eq!(
db.get_recent_channel_messages(channel_id, 50)
.await
.unwrap()[0]
.body,
"first message!"
);
let channels_a = client_a.get_channels().await;
assert_eq!(channels_a.len(), 1);
assert_eq!(channels_a[0].read(&cx_a).name(), "test-channel");
// assert_eq!(
// db.get_recent_channel_messages(channel_id, 50)
// .await
// .unwrap()[0]
// .body,
// "first message!"
// );
}
struct TestServer {

31
zed/src/channel.rs Normal file
View File

@ -0,0 +1,31 @@
use crate::rpc::Client;
use gpui::{Entity, ModelHandle, WeakModelHandle};
use std::{
collections::{HashMap, VecDeque},
sync::Arc,
};
pub struct ChannelList {
channels: HashMap<u64, WeakModelHandle<Channel>>,
rpc: Arc<Client>,
}
pub struct Channel {
id: u64,
name: String,
first_message_id: Option<u64>,
messages: Option<VecDeque<ChannelMessage>>,
rpc: Arc<Client>,
}
pub struct ChannelMessage {
id: u64,
}
enum Event {}
impl Entity for ChannelList {
type Event = Event;
}
impl ChannelList {}

View File

@ -1,4 +1,5 @@
pub mod assets;
pub mod channel;
pub mod editor;
pub mod file_finder;
pub mod fs;

View File

@ -29,6 +29,7 @@ pub struct Client {
pub struct ClientState {
connection_id: Option<ConnectionId>,
pub shared_worktrees: HashMap<u64, WeakModelHandle<Worktree>>,
pub channel_list: Option<WeakModelHandle<ChannelList>>,
pub languages: Arc<LanguageRegistry>,
}