diff --git a/src/activity_manager.rs b/src/activity_manager.rs index 7c74e55..133481e 100644 --- a/src/activity_manager.rs +++ b/src/activity_manager.rs @@ -25,8 +25,6 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -use std::path::PathBuf; - // Deps use crate::filetransfer::FileTransferProtocol; use crate::host::{HostError, Localhost}; @@ -39,6 +37,7 @@ use crate::ui::activities::{ use crate::ui::context::{Context, FileTransferParams}; // Namespaces +use std::path::{Path, PathBuf}; use std::thread::sleep; use std::time::Duration; @@ -63,9 +62,9 @@ impl ActivityManager { /// ### new /// /// Initializes a new Activity Manager - pub fn new(local_dir: &PathBuf, interval: Duration) -> Result { + pub fn new(local_dir: &Path, interval: Duration) -> Result { // Prepare Context - let host: Localhost = match Localhost::new(local_dir.clone()) { + let host: Localhost = match Localhost::new(local_dir.to_path_buf()) { Ok(h) => h, Err(e) => return Err(e), }; diff --git a/src/ui/activities/filetransfer_activity/misc.rs b/src/ui/activities/filetransfer_activity/misc.rs index 6edf440..cc37e65 100644 --- a/src/ui/activities/filetransfer_activity/misc.rs +++ b/src/ui/activities/filetransfer_activity/misc.rs @@ -43,8 +43,6 @@ impl FileTransferActivity { } // Eventually push front the new record self.log_records.push_front(record); - // Set log index - self.log_index = 0; // Update log let msg = self.update_logbox(); self.update(msg); diff --git a/src/ui/activities/filetransfer_activity/mod.rs b/src/ui/activities/filetransfer_activity/mod.rs index b7697a7..6831d16 100644 --- a/src/ui/activities/filetransfer_activity/mod.rs +++ b/src/ui/activities/filetransfer_activity/mod.rs @@ -214,7 +214,6 @@ pub struct FileTransferActivity { remote: FileExplorer, // Remote File explorer state found: Option, // File explorer for find result tab: FileExplorerTab, // Current selected tab - log_index: usize, // Current log index entry selected log_records: VecDeque, // Log records log_size: usize, // Log records size (max) transfer: TransferStates, // Transfer states @@ -244,7 +243,6 @@ impl FileTransferActivity { remote: Self::build_explorer(config_client.as_ref()), found: None, tab: FileExplorerTab::Local, - log_index: 0, log_records: VecDeque::with_capacity(256), // 256 events is enough I guess log_size: 256, // Must match with capacity transfer: TransferStates::default(), diff --git a/src/ui/layout/components/msgbox.rs b/src/ui/layout/components/msgbox.rs index aac4875..2b536e0 100644 --- a/src/ui/layout/components/msgbox.rs +++ b/src/ui/layout/components/msgbox.rs @@ -38,23 +38,10 @@ use tui::{ widgets::{Block, BorderType, List, ListItem}, }; -// -- state - -struct OwnStates { - focus: bool, -} - -impl Default for OwnStates { - fn default() -> Self { - Self { focus: false } - } -} - // -- component pub struct MsgBox { props: Props, - states: OwnStates, } impl MsgBox { @@ -62,10 +49,7 @@ impl MsgBox { /// /// Instantiate a new Text component pub fn new(props: Props) -> Self { - MsgBox { - props, - states: OwnStates::default(), - } + MsgBox { props } } } @@ -179,16 +163,12 @@ impl Component for MsgBox { /// ### blur /// /// Blur component - fn blur(&mut self) { - self.states.focus = false; - } + fn blur(&mut self) {} /// ### active /// /// Active component - fn active(&mut self) { - self.states.focus = true; - } + fn active(&mut self) {} } #[cfg(test)] @@ -217,12 +197,6 @@ mod tests { )) .build(), ); - // Focus - assert_eq!(component.states.focus, false); - component.active(); - assert_eq!(component.states.focus, true); - component.blur(); - assert_eq!(component.states.focus, false); // Get value assert_eq!(component.get_value(), Payload::None); // Event diff --git a/src/ui/layout/components/progress_bar.rs b/src/ui/layout/components/progress_bar.rs index fc5e6e9..93a6438 100644 --- a/src/ui/layout/components/progress_bar.rs +++ b/src/ui/layout/components/progress_bar.rs @@ -34,23 +34,10 @@ use tui::{ widgets::{Block, Gauge}, }; -// -- state - -struct OwnStates { - focus: bool, -} - -impl Default for OwnStates { - fn default() -> Self { - OwnStates { focus: false } - } -} - // -- component pub struct ProgressBar { props: Props, - states: OwnStates, } impl ProgressBar { @@ -58,10 +45,7 @@ impl ProgressBar { /// /// Instantiate a new Progress Bar pub fn new(props: Props) -> Self { - ProgressBar { - props, - states: OwnStates::default(), - } + ProgressBar { props } } } @@ -156,16 +140,12 @@ impl Component for ProgressBar { /// ### blur /// /// Blur component - fn blur(&mut self) { - self.states.focus = false; - } + fn blur(&mut self) {} /// ### active /// /// Active component - fn active(&mut self) { - self.states.focus = true; - } + fn active(&mut self) {} } #[cfg(test)] @@ -186,12 +166,6 @@ mod tests { )) .build(), ); - // Focus - assert_eq!(component.states.focus, false); - component.active(); - assert_eq!(component.states.focus, true); - component.blur(); - assert_eq!(component.states.focus, false); // Get value assert_eq!(component.get_value(), Payload::None); // Event diff --git a/src/ui/layout/components/table.rs b/src/ui/layout/components/table.rs index ac93914..c966f20 100644 --- a/src/ui/layout/components/table.rs +++ b/src/ui/layout/components/table.rs @@ -35,18 +35,6 @@ use tui::{ widgets::{Block, BorderType, List, ListItem}, }; -// -- state - -struct OwnStates { - focus: bool, -} - -impl Default for OwnStates { - fn default() -> Self { - OwnStates { focus: false } - } -} - // -- component /// ## Table @@ -54,7 +42,6 @@ impl Default for OwnStates { /// Table is a table component. List n rows with n text span columns pub struct Table { props: Props, - states: OwnStates, } impl Table { @@ -62,10 +49,7 @@ impl Table { /// /// Instantiate a new Table component pub fn new(props: Props) -> Self { - Table { - props, - states: OwnStates::default(), - } + Table { props } } } @@ -168,16 +152,12 @@ impl Component for Table { /// ### blur /// /// Blur component - fn blur(&mut self) { - self.states.focus = false; - } + fn blur(&mut self) {} /// ### active /// /// Active component - fn active(&mut self) { - self.states.focus = true; - } + fn active(&mut self) {} } #[cfg(test)] @@ -204,12 +184,6 @@ mod tests { )) .build(), ); - // Focus - assert_eq!(component.states.focus, false); - component.active(); - assert_eq!(component.states.focus, true); - component.blur(); - assert_eq!(component.states.focus, false); // Get value assert_eq!(component.get_value(), Payload::None); // Event diff --git a/src/ui/layout/components/title.rs b/src/ui/layout/components/title.rs index e042c9c..47c741d 100644 --- a/src/ui/layout/components/title.rs +++ b/src/ui/layout/components/title.rs @@ -30,23 +30,10 @@ use super::{Canvas, Component, InputEvent, Msg, Payload, Props, PropsBuilder}; // ext use tui::{layout::Rect, style::Style, widgets::Paragraph}; -// -- state - -struct OwnStates { - focus: bool, -} - -impl Default for OwnStates { - fn default() -> Self { - OwnStates { focus: false } - } -} - // -- component pub struct Title { props: Props, - states: OwnStates, } impl Title { @@ -54,10 +41,7 @@ impl Title { /// /// Instantiate a new Title component pub fn new(props: Props) -> Self { - Title { - props, - states: OwnStates::default(), - } + Title { props } } } @@ -134,16 +118,12 @@ impl Component for Title { /// ### blur /// /// Blur component - fn blur(&mut self) { - self.states.focus = false; - } + fn blur(&mut self) {} /// ### active /// /// Active component - fn active(&mut self) { - self.states.focus = true; - } + fn active(&mut self) {} } #[cfg(test)] @@ -161,12 +141,6 @@ mod tests { .with_texts(TextParts::new(Some(String::from("Title")), None)) .build(), ); - // Focus - assert_eq!(component.states.focus, false); - component.active(); - assert_eq!(component.states.focus, true); - component.blur(); - assert_eq!(component.states.focus, false); // Get value assert_eq!(component.get_value(), Payload::None); // Event