aboutsummaryrefslogtreecommitdiff
path: root/src/app.rs
diff options
context:
space:
mode:
authorkrolxon <krolyxon@tutanota.com>2024-04-29 23:20:02 +0530
committerkrolxon <krolyxon@tutanota.com>2024-04-29 23:20:02 +0530
commit87bb8e9473194b47c9f52e49c7fe2b632bd36aef (patch)
tree93c29be7780a6f3677409ad4b1f349ae591dc8d0 /src/app.rs
parentc047f63cd1c727c36c61acacba073eb03b7f8617 (diff)
remove redundant functions and add comments
Diffstat (limited to 'src/app.rs')
-rwxr-xr-xsrc/app.rs36
1 files changed, 14 insertions, 22 deletions
diff --git a/src/app.rs b/src/app.rs
index e38222d..35661e1 100755
--- a/src/app.rs
+++ b/src/app.rs
@@ -15,17 +15,18 @@ pub struct App {
/// check if app is running
pub running: bool,
pub conn: Connection,
- pub queue_list: ContentList<String>,
- pub pl_list: ContentList<String>,
- pub selected_tab: SelectedTab,
- pub browser: FileBrowser,
+ pub browser: FileBrowser, // Directory browser
+ pub queue_list: ContentList<String>, // Stores the current playing queue
+ pub pl_list: ContentList<String>, // Stores list of playlists
+ pub selected_tab: SelectedTab, // Used to switch between tabs
// Search
- pub inputmode: InputMode,
- pub search_input: String,
- pub cursor_position: usize,
+ pub inputmode: InputMode, // Defines input mode, Normal or Search
+ pub search_input: String, // Stores the userinput to be searched
+ pub cursor_position: usize, // Stores the cursor position
- // add to playlists
+ // playlist variables
+ // used to show playlist popup
pub playlist_popup: bool,
pub append_list: ContentList<String>,
}
@@ -90,12 +91,13 @@ impl App {
});
}
+ // Rescan the queue into queue_list
pub fn update_queue(&mut self) {
self.queue_list.list.clear();
Self::get_queue(&mut self.conn, &mut self.queue_list.list);
}
- pub fn get_playlist(conn: &mut Client) -> AppResult<Vec<String>> {
+ fn get_playlist(conn: &mut Client) -> AppResult<Vec<String>> {
let list: Vec<String> = conn.playlists()?.iter().map(|p| p.clone().name).collect();
Ok(list)
}
@@ -110,11 +112,7 @@ impl App {
Ok(list)
}
- pub fn update_playlist(&mut self) -> AppResult<()> {
- Self::get_playlist(&mut self.conn.conn)?;
- Ok(())
- }
-
+ /// Handles the <Space> event key
pub fn handle_add_or_remove_from_current_playlist(&mut self) -> AppResult<()> {
match self.selected_tab {
SelectedTab::DirectoryBrowser => {
@@ -170,6 +168,7 @@ impl App {
Ok(())
}
+ /// Cycle through tabs
pub fn cycle_tabls(&mut self) {
self.selected_tab = match self.selected_tab {
SelectedTab::Queue => SelectedTab::DirectoryBrowser,
@@ -178,6 +177,7 @@ impl App {
};
}
+ /// handles the Enter event on the directory browser
pub fn handle_enter(&mut self) -> AppResult<()> {
let browser = &mut self.browser;
let (t, path) = browser.filetree.get(browser.selected).unwrap();
@@ -218,14 +218,6 @@ impl App {
Ok(())
}
- pub fn search_song(&mut self) -> AppResult<()> {
- if let Some(filename) = self.conn.get_full_path(&self.search_input) {
- let song = self.conn.get_song_with_only_filename(&filename);
- self.conn.push(&song)?;
- }
- Ok(())
- }
-
// Cursor movements
pub fn move_cursor_left(&mut self) {
let cursor_moved_left = self.cursor_position.saturating_sub(1);