From 3708d2cd08beac0ffccadd3d61c477cf139343b5 Mon Sep 17 00:00:00 2001 From: shockrah Date: Sat, 10 Apr 2021 16:56:52 -0700 Subject: [PATCH] Removing websocket changes as they don't architecturally work and thus require too many workarounds A better architecture must be implemented to have good websocket support --- tui/src/cache.rs | 24 ------------------------ tui/src/main.rs | 2 +- 2 files changed, 1 insertion(+), 25 deletions(-) diff --git a/tui/src/cache.rs b/tui/src/cache.rs index ef00dfe..9d31957 100644 --- a/tui/src/cache.rs +++ b/tui/src/cache.rs @@ -105,30 +105,6 @@ impl Cache { .messages.push(msg); } - pub async fn setup_websocket(&mut self, url: String, chan_id: u64) { - use crate::log; - // Ignore inactive server state & NoneType - if let None = self.active_server { return; } - - match connect_async(url.clone()).await { - Ok((ws, _)) => { - let (_tx, rx) = ws.split(); - let reader = rx.for_each(move |message| { - let msg = message.unwrap().into_text().unwrap(); - let msg = api::Message::bogus(msg); - log::file(&msg); - self.new_message(msg, url.clone(), chan_id); - - nop() - }); - //tokio::spawn(reader); - }, - Err(e) => { - log::plain(format!("{}: {}\n", e, url)) - } - }; - } - pub async fn switch_server(&mut self, host: &str) -> (Command, Option) { // TODO: clean this func to be less ugly/easier to read let mut found = false; diff --git a/tui/src/main.rs b/tui/src/main.rs index 385f2b9..5a44878 100644 --- a/tui/src/main.rs +++ b/tui/src/main.rs @@ -231,7 +231,7 @@ async fn main() -> Result<(), Box> { if let Some((url, id)) = app.cache.find_serv(url_portion) { let (cmd, jwt) = app.cache.switch_server(url.as_str()).await; let url = net::ws_url(url.as_str(), jwt); - app.cache.setup_websocket(url, id).await; + // maybe hook some message passing listener here? cmd } else { Command::Failure("No server found".into())