Move stability checks back into room
This commit is contained in:
parent
878467835e
commit
235fd9acc5
3 changed files with 15 additions and 22 deletions
|
|
@ -2,7 +2,6 @@ use std::sync::Arc;
|
|||
|
||||
use crossterm::event::KeyCode;
|
||||
use crossterm::style::{ContentStyle, Stylize};
|
||||
use euphoxide::conn::{Joining, Status};
|
||||
use parking_lot::FairMutex;
|
||||
use toss::terminal::Terminal;
|
||||
|
||||
|
|
@ -16,22 +15,10 @@ use crate::ui::widgets::popup::Popup;
|
|||
use crate::ui::widgets::text::Text;
|
||||
use crate::ui::widgets::BoxedWidget;
|
||||
|
||||
use super::room::RoomStatus;
|
||||
|
||||
pub fn new() -> EditorState {
|
||||
EditorState::new()
|
||||
}
|
||||
|
||||
pub fn stable(status: &RoomStatus) -> bool {
|
||||
matches!(
|
||||
status,
|
||||
RoomStatus::Connected(Status::Joining(Joining {
|
||||
bounce: Some(_),
|
||||
..
|
||||
}))
|
||||
)
|
||||
}
|
||||
|
||||
pub fn widget() -> BoxedWidget {
|
||||
Popup::new(
|
||||
Padding::new(Cursor::new(Text::new((
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use crossterm::event::KeyCode;
|
||||
use euphoxide::conn::{Joined, Status};
|
||||
use euphoxide::conn::Joined;
|
||||
use parking_lot::FairMutex;
|
||||
use toss::styled::Styled;
|
||||
use toss::terminal::Terminal;
|
||||
|
|
@ -14,16 +14,10 @@ use crate::ui::widgets::padding::Padding;
|
|||
use crate::ui::widgets::popup::Popup;
|
||||
use crate::ui::widgets::BoxedWidget;
|
||||
|
||||
use super::room::RoomStatus;
|
||||
|
||||
pub fn new(joined: Joined) -> EditorState {
|
||||
EditorState::with_initial_text(joined.session.name)
|
||||
}
|
||||
|
||||
pub fn stable(status: &RoomStatus) -> bool {
|
||||
matches!(status, RoomStatus::Connected(Status::Joined(_)))
|
||||
}
|
||||
|
||||
pub fn widget(editor: &EditorState) -> BoxedWidget {
|
||||
let editor = editor
|
||||
.widget()
|
||||
|
|
|
|||
|
|
@ -153,8 +153,20 @@ impl EuphRoom {
|
|||
|
||||
fn stabilize_state(&mut self, status: &RoomStatus) {
|
||||
match &self.state {
|
||||
State::Auth(_) if !auth::stable(status) => self.state = State::Normal,
|
||||
State::Nick(_) if !nick::stable(status) => self.state = State::Normal,
|
||||
State::Auth(_)
|
||||
if !matches!(
|
||||
status,
|
||||
RoomStatus::Connected(Status::Joining(Joining {
|
||||
bounce: Some(_),
|
||||
..
|
||||
}))
|
||||
) =>
|
||||
{
|
||||
self.state = State::Normal
|
||||
}
|
||||
State::Nick(_) if !matches!(status, RoomStatus::Connected(Status::Joined(_))) => {
|
||||
self.state = State::Normal
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue