🚧 Add an interface to the ChatsWindows to drive its behavior

For now, only the ChatsWindow tabs are toggled on clicks on room names (from ContactsSection).
This commit is contained in:
2023-12-30 23:31:51 +01:00
parent 2fed770f62
commit 116bbcb247
9 changed files with 208 additions and 92 deletions

28
src/utils.rs Normal file
View File

@@ -0,0 +1,28 @@
use tokio::sync::mpsc::{channel, Receiver as _Receiver, Sender as _Sender};
pub struct Receiver<T>(_Receiver<T>);
impl<T> Receiver<T> {
pub(super) async fn recv(&mut self) -> Option<T> {
self.0.recv().await
}
}
pub struct Sender<T>(_Sender<T>);
// TODO: Handle error
impl<T> Sender<T> {
pub(super) async fn send(self, t: T) {
// self.0.send(t).unwrap();
let _ = self.0.send(t).await;
}
}
// TODO: Rename the name of the following fn
pub fn oneshot<T>() -> (Sender<T>, Receiver<T>) {
let (tx, rx) = channel(32);
let sender = Sender(tx);
let receiver = Receiver(rx);
(sender, receiver)
}