Use new way of creating resources
This commit is contained in:
@ -22,7 +22,7 @@ pub fn AlbumPage() -> impl IntoView {
|
||||
})
|
||||
};
|
||||
|
||||
let song_list = create_resource(
|
||||
let song_list = Resource::new(
|
||||
id,
|
||||
|value| async move {
|
||||
match value {
|
||||
@ -32,7 +32,7 @@ pub fn AlbumPage() -> impl IntoView {
|
||||
},
|
||||
);
|
||||
|
||||
let albumdata = create_resource(
|
||||
let albumdata = Resource::new(
|
||||
id,
|
||||
|value| async move {
|
||||
match value {
|
||||
|
@ -46,7 +46,7 @@ pub fn ArtistPage() -> impl IntoView {
|
||||
|
||||
#[component]
|
||||
fn ArtistIdProfile(#[prop(into)] id: MaybeSignal<i32>) -> impl IntoView {
|
||||
let artist_info = create_resource(move || id.get(), move |id| {
|
||||
let artist_info = Resource::new(move || id.get(), move |id| {
|
||||
get_artist_by_id(id)
|
||||
});
|
||||
|
||||
@ -103,7 +103,7 @@ fn ArtistProfile(artist: Artist) -> impl IntoView {
|
||||
|
||||
#[component]
|
||||
fn TopSongsByArtist(#[prop(into)] artist_id: MaybeSignal<i32>) -> impl IntoView {
|
||||
let top_songs = create_resource(move || artist_id.get(), |artist_id| async move {
|
||||
let top_songs = Resource::new(move || artist_id.get(), |artist_id| async move {
|
||||
let top_songs = top_songs_by_artist(artist_id, Some(10)).await;
|
||||
|
||||
top_songs.map(|top_songs| {
|
||||
@ -148,7 +148,7 @@ fn AlbumsByArtist(#[prop(into)] artist_id: MaybeSignal<i32>) -> impl IntoView {
|
||||
use crate::components::dashboard_row::*;
|
||||
use crate::components::dashboard_tile::*;
|
||||
|
||||
let albums = create_resource(move || artist_id.get(), |artist_id| async move {
|
||||
let albums = Resource::new(move || artist_id.get(), |artist_id| async move {
|
||||
let albums = albums_by_artist(artist_id, None).await;
|
||||
|
||||
albums.map(|albums| {
|
||||
|
@ -92,7 +92,7 @@ fn OwnProfile() -> impl IntoView {
|
||||
/// Show a user's profile by ID
|
||||
#[component]
|
||||
fn UserIdProfile(#[prop(into)] id: MaybeSignal<i32>) -> impl IntoView {
|
||||
let user_info = create_resource(move || id.get(), move |id| {
|
||||
let user_info = Resource::new(move || id.get(), move |id| {
|
||||
get_user_by_id(id)
|
||||
});
|
||||
|
||||
@ -177,7 +177,7 @@ fn UserProfile(user: User) -> impl IntoView {
|
||||
/// Show a list of top songs for a user
|
||||
#[component]
|
||||
fn TopSongs(#[prop(into)] user_id: MaybeSignal<i32>) -> impl IntoView {
|
||||
let top_songs = create_resource(move || user_id.get(), |user_id| async move {
|
||||
let top_songs = Resource::new(move || user_id.get(), |user_id| async move {
|
||||
use chrono::{Local, Duration};
|
||||
let now = Local::now();
|
||||
let start = now - Duration::seconds(HISTORY_SECS);
|
||||
@ -227,7 +227,7 @@ fn TopSongs(#[prop(into)] user_id: MaybeSignal<i32>) -> impl IntoView {
|
||||
/// Show a list of recently played songs for a user
|
||||
#[component]
|
||||
fn RecentSongs(#[prop(into)] user_id: MaybeSignal<i32>) -> impl IntoView {
|
||||
let recent_songs = create_resource(move || user_id.get(), |user_id| async move {
|
||||
let recent_songs = Resource::new(move || user_id.get(), |user_id| async move {
|
||||
let recent_songs = recent_songs(user_id, Some(RECENT_SONGS_COUNT)).await;
|
||||
|
||||
recent_songs.map(|recent_songs| {
|
||||
@ -268,7 +268,7 @@ fn RecentSongs(#[prop(into)] user_id: MaybeSignal<i32>) -> impl IntoView {
|
||||
/// Show a list of top artists for a user
|
||||
#[component]
|
||||
fn TopArtists(#[prop(into)] user_id: MaybeSignal<i32>) -> impl IntoView {
|
||||
let top_artists = create_resource(move || user_id.get(), |user_id| async move {
|
||||
let top_artists = Resource::new(move || user_id.get(), |user_id| async move {
|
||||
use chrono::{Local, Duration};
|
||||
|
||||
let now = Local::now();
|
||||
|
@ -51,7 +51,7 @@ pub fn SongPage() -> impl IntoView {
|
||||
|
||||
#[component]
|
||||
fn SongDetails(#[prop(into)] id: MaybeSignal<i32>) -> impl IntoView {
|
||||
let song_info = create_resource(move || id.get(), move |id| {
|
||||
let song_info = Resource::new(move || id.get(), move |id| {
|
||||
get_song_by_id(id)
|
||||
});
|
||||
|
||||
@ -145,7 +145,7 @@ fn SongOverview(song: SongData) -> impl IntoView {
|
||||
|
||||
#[component]
|
||||
fn SongPlays(#[prop(into)] id: MaybeSignal<i32>) -> impl IntoView {
|
||||
let plays = create_resource(move || id.get(), move |id| songs::get_song_plays(id));
|
||||
let plays = Resource::new(move || id.get(), move |id| songs::get_song_plays(id));
|
||||
|
||||
view! {
|
||||
<Transition
|
||||
@ -174,7 +174,7 @@ fn SongPlays(#[prop(into)] id: MaybeSignal<i32>) -> impl IntoView {
|
||||
|
||||
#[component]
|
||||
fn MySongPlays(#[prop(into)] id: MaybeSignal<i32>) -> impl IntoView {
|
||||
let plays = create_resource(move || id.get(), move |id| songs::get_my_song_plays(id));
|
||||
let plays = Resource::new(move || id.get(), move |id| songs::get_my_song_plays(id));
|
||||
|
||||
view! {
|
||||
<Transition
|
||||
|
@ -24,7 +24,7 @@ impl GlobalState {
|
||||
pub fn new() -> Self {
|
||||
let play_status = create_rw_signal(PlayStatus::default());
|
||||
|
||||
let logged_in_user = create_resource(|| (), |_| async {
|
||||
let logged_in_user = Resource::new(|| (), |_| async {
|
||||
get_logged_in_user().await
|
||||
.inspect_err(|e| {
|
||||
error!("Error getting logged in user: {:?}", e);
|
||||
|
Reference in New Issue
Block a user