Skip to content

Commit

Permalink
fix: adapt imports to new stblib 0.7.0 imports
Browse files Browse the repository at this point in the history
fix: properly exit after unreachable host error
  • Loading branch information
matteodev8 committed Jan 24, 2025
1 parent 5b5e236 commit 23eaf08
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/tui/app.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
use std::io::stdout;
use std::sync::{Arc, RwLock};
use std::time::Duration;
use std::net::TcpStream;
use std::sync::mpsc::{channel};

use crossterm::event;
use crossterm::{event, ExecutableCommand};
use crossterm::event::{Event, KeyCode};

use crossterm::terminal::{disable_raw_mode, LeaveAlternateScreen};
use ratatui::backend::Backend;
use ratatui::style::{Color, Style};
use ratatui::Terminal;
use ratatui::widgets::{Block, Borders};

use stblib::stbm::stbchat::net::{IncomingPacketStream, OutgoingPacketStream};
use stblib::stbchat::net::{IncomingPacketStream, OutgoingPacketStream};

use tui_textarea::TextArea;

Expand Down Expand Up @@ -81,6 +82,8 @@ impl App {
let stream = match TcpStream::connect(host) {
Ok(tcp_stream) => tcp_stream,
Err(_) => {
stdout().execute(LeaveAlternateScreen).unwrap();
disable_raw_mode().unwrap();
eprintln!("Server {}:{} is unreachable. Check if the server is online.", self.address, self.port);
std::process::exit(1);
}
Expand Down

0 comments on commit 23eaf08

Please sign in to comment.