Remove redundant vault
This commit is contained in:
parent
acb03b1f09
commit
f61c03cf0a
1 changed files with 15 additions and 12 deletions
|
|
@ -70,7 +70,6 @@ pub struct EuphRoom {
|
||||||
|
|
||||||
ui_event_tx: mpsc::UnboundedSender<UiEvent>,
|
ui_event_tx: mpsc::UnboundedSender<UiEvent>,
|
||||||
|
|
||||||
vault: EuphRoomVault,
|
|
||||||
room: Option<euph::Room>,
|
room: Option<euph::Room>,
|
||||||
|
|
||||||
focus: Focus,
|
focus: Focus,
|
||||||
|
|
@ -92,7 +91,6 @@ impl EuphRoom {
|
||||||
Self {
|
Self {
|
||||||
config,
|
config,
|
||||||
ui_event_tx,
|
ui_event_tx,
|
||||||
vault: vault.clone(),
|
|
||||||
room: None,
|
room: None,
|
||||||
focus: Focus::Chat,
|
focus: Focus::Chat,
|
||||||
state: State::Normal,
|
state: State::Normal,
|
||||||
|
|
@ -103,6 +101,14 @@ impl EuphRoom {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn vault(&self) -> &EuphRoomVault {
|
||||||
|
self.chat.store()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn name(&self) -> &str {
|
||||||
|
self.vault().room()
|
||||||
|
}
|
||||||
|
|
||||||
async fn shovel_room_events(
|
async fn shovel_room_events(
|
||||||
name: String,
|
name: String,
|
||||||
mut euph_room_event_rx: mpsc::UnboundedReceiver<EuphRoomEvent>,
|
mut euph_room_event_rx: mpsc::UnboundedReceiver<EuphRoomEvent>,
|
||||||
|
|
@ -120,10 +126,8 @@ impl EuphRoom {
|
||||||
|
|
||||||
pub fn connect(&mut self) {
|
pub fn connect(&mut self) {
|
||||||
if self.room.is_none() {
|
if self.room.is_none() {
|
||||||
let store = self.chat.store().clone();
|
|
||||||
let name = store.room().to_string();
|
|
||||||
let (room, euph_room_event_rx) = euph::Room::new(
|
let (room, euph_room_event_rx) = euph::Room::new(
|
||||||
store,
|
self.vault().clone(),
|
||||||
self.config.username.clone(),
|
self.config.username.clone(),
|
||||||
self.config.force_username,
|
self.config.force_username,
|
||||||
self.config.password.clone(),
|
self.config.password.clone(),
|
||||||
|
|
@ -132,7 +136,7 @@ impl EuphRoom {
|
||||||
self.room = Some(room);
|
self.room = Some(room);
|
||||||
|
|
||||||
tokio::task::spawn(Self::shovel_room_events(
|
tokio::task::spawn(Self::shovel_room_events(
|
||||||
name,
|
self.name().to_string(),
|
||||||
euph_room_event_rx,
|
euph_room_event_rx,
|
||||||
self.ui_event_tx.clone(),
|
self.ui_event_tx.clone(),
|
||||||
));
|
));
|
||||||
|
|
@ -167,7 +171,7 @@ impl EuphRoom {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn unseen_msgs_count(&self) -> usize {
|
pub async fn unseen_msgs_count(&self) -> usize {
|
||||||
self.vault.unseen_msgs_count().await
|
self.vault().unseen_msgs_count().await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn stabilize_pseudo_msg(&mut self) {
|
async fn stabilize_pseudo_msg(&mut self) {
|
||||||
|
|
@ -290,9 +294,8 @@ impl EuphRoom {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn status_widget(&self, status: &RoomStatus) -> BoxedWidget {
|
async fn status_widget(&self, status: &RoomStatus) -> BoxedWidget {
|
||||||
let room = self.chat.store().room();
|
|
||||||
let room_style = ContentStyle::default().bold().blue();
|
let room_style = ContentStyle::default().bold().blue();
|
||||||
let mut info = Styled::new(format!("&{room}"), room_style);
|
let mut info = Styled::new(format!("&{}", self.name()), room_style);
|
||||||
|
|
||||||
info = match status {
|
info = match status {
|
||||||
RoomStatus::NoRoom | RoomStatus::Stopped => info.then_plain(", archive"),
|
RoomStatus::NoRoom | RoomStatus::Stopped => info.then_plain(", archive"),
|
||||||
|
|
@ -430,7 +433,7 @@ impl EuphRoom {
|
||||||
match event {
|
match event {
|
||||||
key!('i') => {
|
key!('i') => {
|
||||||
if let Some(id) = self.chat.cursor().await {
|
if let Some(id) = self.chat.cursor().await {
|
||||||
if let Some(msg) = self.vault.full_msg(id).await {
|
if let Some(msg) = self.vault().full_msg(id).await {
|
||||||
self.state = State::InspectMessage(msg);
|
self.state = State::InspectMessage(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -438,14 +441,14 @@ impl EuphRoom {
|
||||||
}
|
}
|
||||||
key!('I') => {
|
key!('I') => {
|
||||||
if let Some(id) = self.chat.cursor().await {
|
if let Some(id) = self.chat.cursor().await {
|
||||||
if let Some(msg) = self.vault.msg(id).await {
|
if let Some(msg) = self.vault().msg(id).await {
|
||||||
self.state = State::Links(LinksState::new(&msg.content));
|
self.state = State::Links(LinksState::new(&msg.content));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
key!(Ctrl + 'p') => {
|
key!(Ctrl + 'p') => {
|
||||||
let link = format!("https://plugh.de/present/{}/", self.vault.room());
|
let link = format!("https://plugh.de/present/{}/", self.name());
|
||||||
if let Err(error) = open::that(&link) {
|
if let Err(error) = open::that(&link) {
|
||||||
self.popups.push_front(RoomPopup::Error {
|
self.popups.push_front(RoomPopup::Error {
|
||||||
description: format!("Failed to open link: {link}"),
|
description: format!("Failed to open link: {link}"),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue