♻️ Replace flume with tokio and share Matrix client infos to chats

- Remove of the flume dependency.
- Add the capability to share data provided by the Matrix client to the ChatsWindow. Indeed, until the 0.6 Dioxus
  release, each window runs in a separate virtual DOM so the context and Fermi states are completely seperate
  (cf. https://discord.com/channels/899851952891002890/1188206938215948378).
This commit is contained in:
2023-12-25 23:14:43 +01:00
parent d7ba8130d3
commit ddeb94e887
8 changed files with 223 additions and 192 deletions

View File

@@ -1,18 +1,34 @@
use std::cell::RefCell;
use std::sync::Arc;
use matrix_sdk::Client as MatrixClient;
use tokio::sync::broadcast::Receiver;
use tokio::sync::mpsc::UnboundedSender;
use super::client::RoomTopicEvent;
use super::worker_tasks::{oneshot, LoginStyle, WorkerTask};
use crate::base::Room;
#[derive(Debug)]
pub struct Receivers {
pub rooms_receiver: RefCell<Receiver<Room>>,
pub room_topic_receiver: RefCell<Receiver<RoomTopicEvent>>,
}
impl Clone for Receivers {
fn clone(&self) -> Self {
Self {
rooms_receiver: RefCell::new(self.rooms_receiver.borrow().resubscribe()),
room_topic_receiver: RefCell::new(self.room_topic_receiver.borrow().resubscribe()),
}
}
}
#[derive(Debug)]
pub struct Requester {
pub matrix_client: Arc<MatrixClient>,
pub tx: UnboundedSender<WorkerTask>,
pub rooms_receiver: flume::Receiver<Room>,
pub room_topic_receiver: flume::Receiver<RoomTopicEvent>,
pub receivers: Receivers,
}
impl Requester {