(
#[prop()] songs: impl Get<Value = Vec<Song>> + Copy + 'static + Send + Sync,
#[prop()] icons: RwSignal<SongDetailIcons>,
#[prop()] selected_songs: RwSignal<Vec<usize>>,
#[prop()] ref
| 43 | )] |
| 44 | #[component()] |
| 45 | pub fn SongView( |
| 46 | #[prop()] songs: impl Get<Value = Vec<Song>> + Copy + 'static + Send + Sync, |
| 47 | #[prop()] icons: RwSignal<SongDetailIcons>, |
| 48 | #[prop()] selected_songs: RwSignal<Vec<usize>>, |
| 49 | #[prop()] refresh_cb: impl Fn() + 'static + Send + Sync, |
| 50 | #[prop()] fetch_next_page: impl Fn() + 'static + Send + Sync, |
| 51 | #[prop(optional)] is_loading: RwSignal<HashMap<String, bool>>, |
| 52 | #[prop(optional)] song_update_request: Option<Box<dyn Fn() + Send + Sync>>, |
| 53 | #[prop(optional)] default_details: RwSignal<DefaultDetails>, |
| 54 | #[prop(optional, default=ShowProvidersArgs::default())] providers: ShowProvidersArgs, |
| 55 | #[prop(optional, default = false)] show_mobile_default_details: bool, |
| 56 | ) -> impl IntoView { |
| 57 | let last_selected_song = RwSignal::new(None::<Song>); |
| 58 | |
| 59 | let filtered_selected = RwSignal::new(vec![]); |
| 60 | |
| 61 | Effect::new(move || { |
| 62 | let selected_song = selected_songs.get().last().cloned(); |
| 63 | if let Some(selected_song) = selected_song { |
| 64 | let all_songs = songs.get(); |
| 65 | tracing::debug!("selected {:?}", all_songs.get(selected_song).unwrap()); |
| 66 | last_selected_song.set(all_songs.get(selected_song).cloned()); |
| 67 | } else { |
| 68 | last_selected_song.set(None); |
| 69 | } |
| 70 | }); |
| 71 | |
| 72 | let song_details_container = NodeRef::<Div>::new(); |
| 73 | let song_list_container = NodeRef::<Div>::new(); |
| 74 | |
| 75 | let ignore__class_list = &[ |
| 76 | "context-menu-root", |
| 77 | "context-menu-outer", |
| 78 | "context-menu-item", |
| 79 | "context-menu-item-text", |
| 80 | "context-menu-item-icon", |
| 81 | "context-menu-right-arrow", |
| 82 | ]; |
| 83 | let ignore_class = move |e: &Event| { |
| 84 | for item in e.composed_path().iter() { |
| 85 | let item: web_sys::HtmlElement = item.into(); |
| 86 | let class_list = item.class_list(); |
| 87 | if class_list.is_undefined() || class_list.is_null() { |
| 88 | continue; |
| 89 | } |
| 90 | |
| 91 | for ele in class_list.values().into_iter().flatten() { |
| 92 | if ignore__class_list.contains(&ele.as_string().unwrap_or_default().as_str()) { |
| 93 | return true; |
| 94 | } |
| 95 | } |
| 96 | } |
| 97 | false |
| 98 | }; |
| 99 | |
| 100 | let _ = on_click_outside(song_details_container, move |e| { |
| 101 | if ignore_class(&e) { |
| 102 | return; |
nothing calls this directly
no test coverage detected