Remove unnecessary async-iness
This commit is contained in:
parent
b18b71f3d6
commit
4d204109f1
3 changed files with 16 additions and 18 deletions
|
|
@ -368,8 +368,7 @@ impl CoveConnMt {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO Make sync
|
||||
pub async fn new(
|
||||
pub fn new(
|
||||
url: String,
|
||||
room: String,
|
||||
timeout: Duration,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
||||
use tokio::runtime::Runtime;
|
||||
use tokio::sync::mpsc::{self, UnboundedReceiver, UnboundedSender};
|
||||
use tokio::sync::oneshot::{self, Sender};
|
||||
use tokio::sync::{Mutex, MutexGuard};
|
||||
|
|
@ -18,14 +19,13 @@ struct ConnConfig {
|
|||
}
|
||||
|
||||
impl ConnConfig {
|
||||
async fn new_conn(&self) -> (CoveConn, CoveConnMt) {
|
||||
fn new_conn(&self) -> (CoveConn, CoveConnMt) {
|
||||
conn::new(
|
||||
self.url.clone(),
|
||||
self.room.clone(),
|
||||
self.timeout,
|
||||
self.ev_tx.clone(),
|
||||
)
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -39,7 +39,9 @@ pub struct CoveRoom {
|
|||
}
|
||||
|
||||
impl CoveRoom {
|
||||
pub async fn new<E, F>(
|
||||
/// This method uses [`tokio::spawn`] and must thus be called in the context
|
||||
/// of a tokio runtime.
|
||||
pub fn new<E, F>(
|
||||
config: &'static Config,
|
||||
name: String,
|
||||
event_sender: UnboundedSender<E>,
|
||||
|
|
@ -58,7 +60,7 @@ impl CoveRoom {
|
|||
room: name.clone(),
|
||||
timeout: config.timeout,
|
||||
};
|
||||
let (conn, mt) = conf.new_conn().await;
|
||||
let (conn, mt) = conf.new_conn();
|
||||
|
||||
let room = Self {
|
||||
name: name.clone(),
|
||||
|
|
@ -122,7 +124,7 @@ impl CoveRoom {
|
|||
url_exists = true;
|
||||
|
||||
// TODO Clean up with restructuring assignments later?
|
||||
let (new_conn, new_mt) = conf.new_conn().await;
|
||||
let (new_conn, new_mt) = conf.new_conn();
|
||||
*conn.lock().await = new_conn;
|
||||
mt = new_mt;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -182,7 +182,7 @@ impl Ui {
|
|||
Some(OverlayReaction::Close) => self.overlay = None,
|
||||
Some(OverlayReaction::SwitchRoom(id)) => {
|
||||
self.overlay = None;
|
||||
self.switch_to_room(id).await;
|
||||
self.switch_to_room(id);
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
|
|
@ -197,13 +197,11 @@ impl Ui {
|
|||
event: KeyEvent,
|
||||
) -> Option<EventHandleResult> {
|
||||
match &self.room {
|
||||
Some(RoomId::Cove(name)) => {
|
||||
if let Some(ui) = self.cove_rooms.get_mut(name) {
|
||||
ui.handle_key(event).map(|_| EventHandleResult::Continue)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
Some(RoomId::Cove(name)) => self
|
||||
.cove_rooms
|
||||
.get_mut(name)
|
||||
.and_then(|ui| ui.handle_key(event))
|
||||
.and(Some(EventHandleResult::Continue)),
|
||||
None => None,
|
||||
}
|
||||
}
|
||||
|
|
@ -344,7 +342,7 @@ impl Ui {
|
|||
}
|
||||
}
|
||||
|
||||
async fn switch_to_room(&mut self, id: RoomId) {
|
||||
fn switch_to_room(&mut self, id: RoomId) {
|
||||
match &id {
|
||||
RoomId::Cove(name) => {
|
||||
if let Entry::Vacant(entry) = self.cove_rooms.entry(name.clone()) {
|
||||
|
|
@ -353,8 +351,7 @@ impl Ui {
|
|||
name.clone(),
|
||||
self.event_tx.clone(),
|
||||
UiEvent::cove,
|
||||
)
|
||||
.await;
|
||||
);
|
||||
entry.insert(CoveUi::new(room));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue