MCPcopy Create free account
hub / github.com/Moosync/Moosync / remove_from_playlist

Method remove_from_playlist

src/utils/context_menu.rs:162–195  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

160 }
161
162 pub fn remove_from_playlist(&self) {
163 let params = use_query_map();
164 let playlist = Memo::new(move |_| {
165 params.with(|params| {
166 let entity = params.get("entity");
167 if let Some(entity) = entity {
168 let playlist = serde_json::from_str::<QueryablePlaylist>(&entity);
169 if let Ok(playlist) = playlist {
170 return Some(playlist);
171 }
172 }
173 None
174 })
175 });
176
177 let playlist = playlist.get();
178 if let Some(playlist_id) = playlist.and_then(|p| p.playlist_id) {
179 let selected_songs = self
180 .current_or_list()
181 .into_iter()
182 .filter_map(|s| s.song._id)
183 .collect();
184 let refresh_cb = self.refresh_cb.clone();
185 spawn_local(async move {
186 let res =
187 crate::utils::invoke::remove_from_playlist(playlist_id, selected_songs).await;
188 if let Err(e) = res {
189 tracing::error!("Error removing songs from playlist: {:?}", e);
190 } else {
191 refresh_cb.as_ref()();
192 }
193 });
194 }
195 }
196}
197
198impl<T> ContextMenuData<Self> for SongItemContextMenu<T>

Callers 1

get_menu_itemsMethod · 0.45

Calls 3

getMethod · 0.80
current_or_listMethod · 0.80
cloneMethod · 0.80

Tested by

no test coverage detected