This commit is contained in:
Chris Cochrun 2025-03-06 11:56:04 -06:00
parent d1ae7ba4f5
commit e63f003181

View file

@ -110,14 +110,14 @@ impl<'a> Library {
error!("Not editing a song item"); error!("Not editing a song item");
return Task::none(); return Task::none();
} }
let mut db = self.db.clone(); let db = self.db.clone();
let mut song_library = self.song_library.clone(); let song_library = self.song_library.clone();
let future = update_song( let future = update_song(
song, song,
index as usize, index as usize,
&mut db, db,
&mut song_library, song_library,
); );
Task::perform(future, |r| { Task::perform(future, |r| {
match r { match r {
@ -374,6 +374,8 @@ impl<'a> Library {
pub(crate) async fn update_song( pub(crate) async fn update_song(
&'a mut self, &'a mut self,
song: Song, song: Song,
mut db: SqliteConnection,
mut song_library: Model<Song>,
) -> Result<()> { ) -> Result<()> {
let Some((kind, index)) = self.editing_item else { let Some((kind, index)) = self.editing_item else {
return Err(miette!("Not editing an item")); return Err(miette!("Not editing an item"));
@ -384,11 +386,7 @@ impl<'a> Library {
} }
if let Some(_) = self.song_library.items.get(index as usize) { if let Some(_) = self.song_library.items.get(index as usize) {
let mut db = self.db.acquire().await.expect("probs"); song_library.update_song(song, index, &mut db).await?;
self.song_library
.update_song(song, index, &mut db)
.await?;
Ok(()) Ok(())
} else { } else {
Err(miette!("Song not found")) Err(miette!("Song not found"))