From 2e5fe439b03c0b6e6c27100d78a48ecc3bba1dae Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Mon, 6 Apr 2026 14:43:27 -0500 Subject: [PATCH] fix some issues --- src/core/songs.rs | 4 ++-- src/ui/library.rs | 21 ++++++++------------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/core/songs.rs b/src/core/songs.rs index 77ddee2..4b8e009 100644 --- a/src/core/songs.rs +++ b/src/core/songs.rs @@ -789,7 +789,7 @@ pub async fn remove_from_db( .map(|_| ()) } -pub async fn add_song_to_db( +pub async fn new_song_from_db( db: PoolConnection, ) -> Result { let mut song = Song::default(); @@ -1357,7 +1357,7 @@ You saved my soul" async fn fill_db(db: &SqlitePool) -> Result<()> { for _ in 0..20 { let conn = db.acquire().await.into_diagnostic()?; - let db_song = add_song_to_db(conn).await?; + let db_song = new_song_from_db(conn).await?; let mut song = test_song(); song.id = db_song.id; let conn = db.acquire().await.into_diagnostic()?; diff --git a/src/ui/library.rs b/src/ui/library.rs index 10b2740..374c491 100644 --- a/src/ui/library.rs +++ b/src/ui/library.rs @@ -34,7 +34,7 @@ use crate::core::{ update_presentation_in_db, }, service_items::ServiceItem, - songs::{self, Song, add_song_to_db, update_song_in_db}, + songs::{self, Song, new_song_from_db, update_song_in_db}, videos::{self, Video, add_video_to_db, update_video_in_db}, }; @@ -171,25 +171,20 @@ impl<'a> Library { self.library_open.unwrap_or(LibraryKind::Song); match kind { LibraryKind::Song => { + let index = (self.song_library.items.len() + - 1) + as i32; + let task = Task::future(self.db.acquire()) .map_err(|e| { miette::miette!("Database error: {e}") }) .and_then(move |db| { Task::perform( - self.song_library.new_song(db), + new_song_from_db(db), move |res| { res.map(|song| { - let index = (self - .song_library - .items - .len() - - 1) - as i32; - Message::OpenItem(Some(( - LibraryKind::Song, - index, - ))) + Message::AddSong(song) }) }, ) @@ -698,7 +693,7 @@ impl<'a> Library { }) .and_then(move |db| { Task::perform( - add_song_to_db(db), + new_song_from_db(db), { move |res| { res.map(|_song| {