Working Albums Page (BETA)
This commit is contained in:
@ -13,25 +13,20 @@ cfg_if! {
|
||||
}
|
||||
}
|
||||
|
||||
// #[server(endpoint = "album/get")]
|
||||
// pub async fn get_album(id: Option<i32>) -> Result<Album, ServerFnError> {
|
||||
// let db_con = &mut get_db_conn();
|
||||
// let album = Album::get_album(id,db_con)
|
||||
// .map_err(|e| ServerFnError::<NoCustomError>::ServerError(format!("Error getting album: {}", e)))?;
|
||||
// Ok(album)
|
||||
// }
|
||||
#[server(endpoint = "album/get")]
|
||||
pub async fn get_album(id: i32) -> Result<Album, ServerFnError> {
|
||||
let db_con = &mut get_db_conn();
|
||||
let album = Album::get_album(id,db_con)
|
||||
.map_err(|e| ServerFnError::<NoCustomError>::ServerError(format!("Error getting album: {}", e)))?;
|
||||
Ok(album)
|
||||
}
|
||||
|
||||
// #[server(endpoint = "album/get_songs")]
|
||||
// pub async fn get_songs(album: Option<Album>) -> Result<Vec<Song>, ServerFnError> {
|
||||
// let db_con = &mut get_db_conn();
|
||||
// let songs = album.get_songs(db_con)
|
||||
// .map_err(|e| ServerFnError::<NoCustomError>::ServerError(format!("Error getting album: {}", e)))?;
|
||||
// Ok(songs)
|
||||
// }
|
||||
|
||||
// #[server(endpoint = "album/get_song_list")]
|
||||
// pub async fn get_song_data(album: Option<Album>) -> Result<Vec<Song>, ServerFnError> {
|
||||
// let user = get_user().await?;
|
||||
// let db_con = &mut get_db_conn();
|
||||
// // TODO: NEEDS SONG DATA QUERIES
|
||||
// }
|
||||
#[server(endpoint = "album/get_songs")]
|
||||
pub async fn get_songs(id: i32) -> Result<Vec<SongData>, ServerFnError> {
|
||||
let user = get_user().await?;
|
||||
let db_con = &mut get_db_conn();
|
||||
// TODO: NEEDS SONG DATA QUERIES
|
||||
let songdata = Album::get_song_data(id,user.id.unwrap(),db_con)
|
||||
.map_err(|e| ServerFnError::<NoCustomError>::ServerError(format!("Error getting song data: {}", e)))?;
|
||||
Ok(songdata)
|
||||
}
|
Reference in New Issue
Block a user