fix some issues
This commit is contained in:
parent
69410e3b6e
commit
2e5fe439b0
2 changed files with 10 additions and 15 deletions
|
|
@ -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<Sqlite>,
|
||||
) -> Result<Song> {
|
||||
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()?;
|
||||
|
|
|
|||
|
|
@ -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| {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue