Use Signal instead of MaybeSignal
This commit is contained in:
parent
ec1c57a67d
commit
abd0f87d41
@ -85,7 +85,7 @@ fn SongListInner<T>(songs: Vec<(SongData, T)>, show_extra: bool) -> impl IntoVie
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn SongListItem<T>(song: SongData, song_playing: MaybeSignal<bool>, extra: Option<T>,
|
pub fn SongListItem<T>(song: SongData, song_playing: Signal<bool>, extra: Option<T>,
|
||||||
list_index: usize, do_queue_remaining: WriteSignal<Option<usize>>) -> impl IntoView where
|
list_index: usize, do_queue_remaining: WriteSignal<Option<usize>>) -> impl IntoView where
|
||||||
T: IntoView + 'static
|
T: IntoView + 'static
|
||||||
{
|
{
|
||||||
@ -115,7 +115,7 @@ pub fn SongListItem<T>(song: SongData, song_playing: MaybeSignal<bool>, extra: O
|
|||||||
/// Display the song's image, with an overlay if the song is playing
|
/// Display the song's image, with an overlay if the song is playing
|
||||||
/// When the song list item is hovered, the overlay will show the play button
|
/// When the song list item is hovered, the overlay will show the play button
|
||||||
#[component]
|
#[component]
|
||||||
pub fn SongImage(image_path: String, song_playing: MaybeSignal<bool>, list_index: usize,
|
pub fn SongImage(image_path: String, song_playing: Signal<bool>, list_index: usize,
|
||||||
do_queue_remaining: WriteSignal<Option<usize>>) -> impl IntoView
|
do_queue_remaining: WriteSignal<Option<usize>>) -> impl IntoView
|
||||||
{
|
{
|
||||||
let play_song = move |_| {
|
let play_song = move |_| {
|
||||||
@ -183,7 +183,7 @@ pub fn SongAlbum(album: Option<Album>) -> impl IntoView {
|
|||||||
#[component]
|
#[component]
|
||||||
pub fn SongLikeDislike(
|
pub fn SongLikeDislike(
|
||||||
#[prop(into)]
|
#[prop(into)]
|
||||||
song_id: MaybeSignal<i32>,
|
song_id: Signal<i32>,
|
||||||
liked: RwSignal<bool>,
|
liked: RwSignal<bool>,
|
||||||
disliked: RwSignal<bool>) -> impl IntoView
|
disliked: RwSignal<bool>) -> impl IntoView
|
||||||
{
|
{
|
||||||
|
@ -46,7 +46,7 @@ pub fn ArtistPage() -> impl IntoView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
fn ArtistIdProfile(#[prop(into)] id: MaybeSignal<i32>) -> impl IntoView {
|
fn ArtistIdProfile(#[prop(into)] id: Signal<i32>) -> impl IntoView {
|
||||||
let artist_info = Resource::new(move || id.get(), move |id| {
|
let artist_info = Resource::new(move || id.get(), move |id| {
|
||||||
get_artist_by_id(id)
|
get_artist_by_id(id)
|
||||||
});
|
});
|
||||||
@ -103,7 +103,7 @@ fn ArtistProfile(artist: Artist) -> impl IntoView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
fn TopSongsByArtist(#[prop(into)] artist_id: MaybeSignal<i32>) -> impl IntoView {
|
fn TopSongsByArtist(#[prop(into)] artist_id: Signal<i32>) -> impl IntoView {
|
||||||
let top_songs = Resource::new(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;
|
let top_songs = top_songs_by_artist(artist_id, Some(10)).await;
|
||||||
|
|
||||||
@ -145,7 +145,7 @@ fn TopSongsByArtist(#[prop(into)] artist_id: MaybeSignal<i32>) -> impl IntoView
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
fn AlbumsByArtist(#[prop(into)] artist_id: MaybeSignal<i32>) -> impl IntoView {
|
fn AlbumsByArtist(#[prop(into)] artist_id: Signal<i32>) -> impl IntoView {
|
||||||
use crate::components::dashboard_row::*;
|
use crate::components::dashboard_row::*;
|
||||||
|
|
||||||
let albums = Resource::new(move || artist_id.get(), |artist_id| async move {
|
let albums = Resource::new(move || artist_id.get(), |artist_id| async move {
|
||||||
|
@ -91,7 +91,7 @@ fn OwnProfile() -> impl IntoView {
|
|||||||
|
|
||||||
/// Show a user's profile by ID
|
/// Show a user's profile by ID
|
||||||
#[component]
|
#[component]
|
||||||
fn UserIdProfile(#[prop(into)] id: MaybeSignal<i32>) -> impl IntoView {
|
fn UserIdProfile(#[prop(into)] id: Signal<i32>) -> impl IntoView {
|
||||||
let user_info = Resource::new(move || id.get(), move |id| {
|
let user_info = Resource::new(move || id.get(), move |id| {
|
||||||
get_user_by_id(id)
|
get_user_by_id(id)
|
||||||
});
|
});
|
||||||
@ -176,7 +176,7 @@ fn UserProfile(user: User) -> impl IntoView {
|
|||||||
|
|
||||||
/// Show a list of top songs for a user
|
/// Show a list of top songs for a user
|
||||||
#[component]
|
#[component]
|
||||||
fn TopSongs(#[prop(into)] user_id: MaybeSignal<i32>) -> impl IntoView {
|
fn TopSongs(#[prop(into)] user_id: Signal<i32>) -> impl IntoView {
|
||||||
let top_songs = Resource::new(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};
|
use chrono::{Local, Duration};
|
||||||
let now = Local::now();
|
let now = Local::now();
|
||||||
@ -226,7 +226,7 @@ fn TopSongs(#[prop(into)] user_id: MaybeSignal<i32>) -> impl IntoView {
|
|||||||
|
|
||||||
/// Show a list of recently played songs for a user
|
/// Show a list of recently played songs for a user
|
||||||
#[component]
|
#[component]
|
||||||
fn RecentSongs(#[prop(into)] user_id: MaybeSignal<i32>) -> impl IntoView {
|
fn RecentSongs(#[prop(into)] user_id: Signal<i32>) -> impl IntoView {
|
||||||
let recent_songs = Resource::new(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;
|
let recent_songs = recent_songs(user_id, Some(RECENT_SONGS_COUNT)).await;
|
||||||
|
|
||||||
@ -267,7 +267,7 @@ fn RecentSongs(#[prop(into)] user_id: MaybeSignal<i32>) -> impl IntoView {
|
|||||||
|
|
||||||
/// Show a list of top artists for a user
|
/// Show a list of top artists for a user
|
||||||
#[component]
|
#[component]
|
||||||
fn TopArtists(#[prop(into)] user_id: MaybeSignal<i32>) -> impl IntoView {
|
fn TopArtists(#[prop(into)] user_id: Signal<i32>) -> impl IntoView {
|
||||||
let top_artists = Resource::new(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};
|
use chrono::{Local, Duration};
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ pub fn SongPage() -> impl IntoView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
fn SongDetails(#[prop(into)] id: MaybeSignal<i32>) -> impl IntoView {
|
fn SongDetails(#[prop(into)] id: Signal<i32>) -> impl IntoView {
|
||||||
let song_info = Resource::new(move || id.get(), move |id| {
|
let song_info = Resource::new(move || id.get(), move |id| {
|
||||||
get_song_by_id(id)
|
get_song_by_id(id)
|
||||||
});
|
});
|
||||||
@ -145,7 +145,7 @@ fn SongOverview(song: SongData) -> impl IntoView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
fn SongPlays(#[prop(into)] id: MaybeSignal<i32>) -> impl IntoView {
|
fn SongPlays(#[prop(into)] id: Signal<i32>) -> impl IntoView {
|
||||||
let plays = Resource::new(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! {
|
view! {
|
||||||
@ -174,7 +174,7 @@ fn SongPlays(#[prop(into)] id: MaybeSignal<i32>) -> impl IntoView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
fn MySongPlays(#[prop(into)] id: MaybeSignal<i32>) -> impl IntoView {
|
fn MySongPlays(#[prop(into)] id: Signal<i32>) -> impl IntoView {
|
||||||
let plays = Resource::new(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! {
|
view! {
|
||||||
|
@ -230,7 +230,7 @@ fn PlayControls() -> impl IntoView {
|
|||||||
|
|
||||||
/// The elapsed time and total time of the current song
|
/// The elapsed time and total time of the current song
|
||||||
#[component]
|
#[component]
|
||||||
fn PlayDuration(elapsed_secs: MaybeSignal<i64>, total_secs: MaybeSignal<i64>) -> impl IntoView {
|
fn PlayDuration(elapsed_secs: Signal<i64>, total_secs: Signal<i64>) -> impl IntoView {
|
||||||
// Create a derived signal that formats the elapsed and total seconds into a string
|
// Create a derived signal that formats the elapsed and total seconds into a string
|
||||||
let play_duration = Signal::derive(move || {
|
let play_duration = Signal::derive(move || {
|
||||||
let elapsed_mins = (elapsed_secs.get() - elapsed_secs.get() % 60) / 60;
|
let elapsed_mins = (elapsed_secs.get() - elapsed_secs.get() % 60) / 60;
|
||||||
@ -407,7 +407,7 @@ fn LikeDislike() -> impl IntoView {
|
|||||||
|
|
||||||
/// The play progress bar, and click handler for skipping to a certain time in the song
|
/// The play progress bar, and click handler for skipping to a certain time in the song
|
||||||
#[component]
|
#[component]
|
||||||
fn ProgressBar(percentage: MaybeSignal<f64>) -> impl IntoView {
|
fn ProgressBar(percentage: Signal<f64>) -> impl IntoView {
|
||||||
// Keep a reference to the progress bar div so we can get its width and calculate the time to skip to
|
// Keep a reference to the progress bar div so we can get its width and calculate the time to skip to
|
||||||
let progress_bar_ref = NodeRef::<Div>::new();
|
let progress_bar_ref = NodeRef::<Div>::new();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user