use eframe::egui::{self, Sense}; use futures::executor::block_on; use matrix_sdk::Client; use super::Id; /// Logged in application state #[derive(Debug)] pub struct App { client: matrix_sdk::Client, selected_room: Option, } impl App { pub fn with_client(client: Client) -> Self { Self { client, selected_room: None, } } pub fn update(&mut self, ctx: &egui::CtxRef) { egui::SidePanel::left(Id::RoomPanel) .max_width(800.0) .show(ctx, |ui| { ui.add(egui::Label::new("Joined").strong()); for room in self.client.joined_rooms() { let response = ui.group(|ui| { if let Some(name) = room.name() { ui.label(name.to_string()); } if let Some(alias) = room.canonical_alias() { ui.label(alias.to_string()); } }); let response = response.response.interact(Sense::click()); if response.clicked() { self.selected_room = Some(room.room_id().clone()); } } }); } }