Use RwSignal::new instead of create_rw_signal

This commit is contained in:
2024-12-28 15:47:06 -05:00
parent 628684a259
commit 57406b5940
14 changed files with 25 additions and 25 deletions

View File

@ -39,9 +39,9 @@ pub fn App() -> impl IntoView {
provide_context(GlobalState::new());
let upload_open = create_rw_signal(false);
let add_artist_open = create_rw_signal(false);
let add_album_open = create_rw_signal(false);
let upload_open = RwSignal::new(false);
let add_artist_open = RwSignal::new(false);
let add_album_open = RwSignal::new(false);
view! {
// injects a stylesheet into the document <head>

View File

@ -17,9 +17,9 @@ pub fn AddAlbumBtn(add_album_open: RwSignal<bool>) -> impl IntoView {
}
#[component]
pub fn AddAlbum(open: RwSignal<bool>) -> impl IntoView {
let album_title = create_rw_signal("".to_string());
let release_date = create_rw_signal("".to_string());
let image_path = create_rw_signal("".to_string());
let album_title = RwSignal::new("".to_string());
let release_date = RwSignal::new("".to_string());
let image_path = RwSignal::new("".to_string());
let close_dialog = move |ev: leptos::ev::MouseEvent| {
ev.prevent_default();

View File

@ -17,7 +17,7 @@ pub fn AddArtistBtn(add_artist_open: RwSignal<bool>) -> impl IntoView {
}
#[component]
pub fn AddArtist(open: RwSignal<bool>) -> impl IntoView {
let artist_name = create_rw_signal("".to_string());
let artist_name = RwSignal::new("".to_string());
let close_dialog = move |ev: leptos::ev::MouseEvent| {
ev.prevent_default();

View File

@ -8,7 +8,7 @@ pub fn Sidebar(upload_open: RwSignal<bool>, add_artist_open: RwSignal<bool>, add
use leptos_router::hooks::use_location;
let location = use_location();
let dropdown_open = create_rw_signal(false);
let dropdown_open = RwSignal::new(false);
let on_dashboard = Signal::derive(
move || location.pathname.get().starts_with("/dashboard") || location.pathname.get() == "/",

View File

@ -66,7 +66,7 @@ fn SongListInner<T>(songs: Vec<(SongData, T)>, show_extra: bool) -> impl IntoVie
{
songs_2.iter().enumerate().map(|(list_index, (song, extra))| {
let song_id = song.id;
let playing = create_rw_signal(false);
let playing = RwSignal::new(false);
create_effect(move |_| {
GlobalState::play_status().with(|status| {
@ -90,8 +90,8 @@ pub fn SongListItem<T>(song: SongData, song_playing: MaybeSignal<bool>, extra: O
list_index: usize, do_queue_remaining: WriteSignal<Option<usize>>) -> impl IntoView where
T: IntoView + 'static
{
let liked = create_rw_signal(song.like_dislike.map(|(liked, _)| liked).unwrap_or(false));
let disliked = create_rw_signal(song.like_dislike.map(|(_, disliked)| disliked).unwrap_or(false));
let liked = RwSignal::new(song.like_dislike.map(|(liked, _)| liked).unwrap_or(false));
let disliked = RwSignal::new(song.like_dislike.map(|(_, disliked)| disliked).unwrap_or(false));
view! {
<tr class="song-list-item">

View File

@ -27,7 +27,7 @@ pub fn ErrorTemplate(
#[prop(optional)] errors: Option<RwSignal<Errors>>,
) -> impl IntoView {
let errors = match outside_errors {
Some(e) => create_rw_signal(e),
Some(e) => RwSignal::new(e),
None => match errors {
Some(e) => e,
None => panic!("No Errors found and we expected errors!"),

View File

@ -51,7 +51,7 @@ fn ArtistIdProfile(#[prop(into)] id: MaybeSignal<i32>) -> impl IntoView {
get_artist_by_id(id)
});
let show_details = create_rw_signal(false);
let show_details = RwSignal::new(false);
view! {
<Transition

View File

@ -14,8 +14,8 @@ pub fn Login() -> impl IntoView {
let (show_password, set_show_password) = create_signal(false);
let loading = create_rw_signal(false);
let error_msg = create_rw_signal(None);
let loading = RwSignal::new(false);
let error_msg = RwSignal::new(None);
let toggle_password = move |_| {
set_show_password.update(|show_password| *show_password = !*show_password);

View File

@ -97,7 +97,7 @@ fn UserIdProfile(#[prop(into)] id: MaybeSignal<i32>) -> impl IntoView {
});
// Show the details if the user is found
let show_details = create_rw_signal(false);
let show_details = RwSignal::new(false);
view!{
<Transition

View File

@ -15,8 +15,8 @@ pub fn Signup() -> impl IntoView {
let (show_password, set_show_password) = create_signal(false);
let loading = create_rw_signal(false);
let error_msg = create_rw_signal(None);
let loading = RwSignal::new(false);
let error_msg = RwSignal::new(None);
let toggle_password = move |_| {
set_show_password.update(|show_password| *show_password = !*show_password);

View File

@ -91,10 +91,10 @@ fn SongDetails(#[prop(into)] id: MaybeSignal<i32>) -> impl IntoView {
#[component]
fn SongOverview(song: SongData) -> impl IntoView {
let liked = create_rw_signal(song.like_dislike.map(|ld| ld.0).unwrap_or(false));
let disliked = create_rw_signal(song.like_dislike.map(|ld| ld.1).unwrap_or(false));
let liked = RwSignal::new(song.like_dislike.map(|ld| ld.0).unwrap_or(false));
let disliked = RwSignal::new(song.like_dislike.map(|ld| ld.1).unwrap_or(false));
let playing = create_rw_signal(false);
let playing = RwSignal::new(false);
let icon = Signal::derive(move || {
if playing.get() {
icondata::BsPauseFill

View File

@ -568,7 +568,7 @@ pub fn PlayBar() -> impl IntoView {
});
// Track the last song that was added to the history to prevent duplicates
let last_history_song_id = create_rw_signal(None);
let last_history_song_id = RwSignal::new(None);
let Pausable {
is_active: hist_timeout_pending,

View File

@ -33,9 +33,9 @@ pub fn Queue() -> impl IntoView {
e.prevent_default();
};
let index_being_dragged = create_rw_signal(-1);
let index_being_dragged = RwSignal::new(-1);
let index_being_hovered = create_rw_signal(-1);
let index_being_hovered = RwSignal::new(-1);
let on_drag_start = move |_e: DragEvent, index: usize| {
// set the index of the item being dragged

View File

@ -22,7 +22,7 @@ pub struct GlobalState {
impl GlobalState {
pub fn new() -> Self {
let play_status = create_rw_signal(PlayStatus::default());
let play_status = RwSignal::new(PlayStatus::default());
let logged_in_user = Resource::new(|| (), |_| async {
get_logged_in_user().await