aboutsummaryrefslogtreecommitdiff
path: root/src/app.rs
diff options
context:
space:
mode:
authorkrolxon <krolyxon@tutanota.com>2024-06-01 15:58:53 +0530
committerkrolxon <krolyxon@tutanota.com>2024-06-01 15:58:53 +0530
commitdc3f561de36fdfc283ebe0b6cf49f09f3bdc9282 (patch)
tree84dfc38712a631f57450da63351fa946689a4da1 /src/app.rs
parent311cbc26318ef81e1b7c697e11098fb6b642fd2c (diff)
fix #8
Diffstat (limited to 'src/app.rs')
-rwxr-xr-xsrc/app.rs26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/app.rs b/src/app.rs
index a76d0cd..06d76ce 100755
--- a/src/app.rs
+++ b/src/app.rs
@@ -30,6 +30,9 @@ pub struct App {
// used to show playlist popup
pub playlist_popup: bool,
pub append_list: ContentList<String>,
+
+ // Determines if the database should be updated or not
+ pub should_update_song_list: bool,
}
#[derive(Debug, PartialEq, Clone)]
@@ -67,12 +70,33 @@ impl App {
pl_cursor_pos: 0,
playlist_popup: false,
append_list,
+ should_update_song_list: false,
})
}
- pub fn tick(&mut self) {
+ pub fn tick(&mut self) -> AppResult<()> {
self.conn.update_status();
self.update_queue();
+
+ // Deals with database update
+ if self.should_update_song_list {
+ if let None = self.conn.status.updating_db {
+ // Update the songs list
+ self.conn.songs_filenames = self
+ .conn
+ .conn
+ .listall()?
+ .into_iter()
+ .map(|x| x.file)
+ .collect();
+
+ self.browser.update_directory(&mut self.conn)?;
+
+ self.should_update_song_list = false;
+ }
+ }
+
+ Ok(())
}
pub fn quit(&mut self) {