misterdownloadmanager: The ultimate open-source, clean-room download manager written from scratch in pure Rust for Windows, Mac, and Linux
Rust bittorrent-clientdebriddownload-acceleratordownload-managerdownloadmanagereguifile-downloadergallery-dlidmidm-alternativeinternet-download-managerm3u8-downloadermagnetplaylist-downloaderreal-debridrusttorrent-clientvideo-downloaderyoutube-downloaderyt-dlp
fix(app): re-evaluate selected feed after removing a feed in RSS window (#321) (#340)
R ! Y 4 Z135f4f2281ce
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 9d036f6d..aef7462e 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -18,6 +18,7 @@ Each release's notes on GitHub come from its section here (`## [X.Y.Z]`, see### Fixed+- Removing the last feed in the RSS feeds window no longer crashes the app ([#321](https://github.com/anefzaoui/misterdownloadmanager/issues/321)).- **YouTube formats with Node.js or Bun installed** ([#360](https://github.com/anefzaoui/misterdownloadmanager/issues/360)): yt-dlp needs a JavaScript runtime for them and looks for Deno alone, so MDM now tells it about Node.js (nvm's too) or Bun when there is no Deno.- **YouTube's look-up failing with "Requested format is not available"** ([#352](https://github.com/anefzaoui/misterdownloadmanager/issues/352)): signed-in cookies make yt-dlp use only YouTube's players that need a JavaScript runtime, and without one no video is left. The page is now looked up again without the cookies, and lists its qualities.- **Download video offering only the sound, with no reason given** ([#351](https://github.com/anefzaoui/misterdownloadmanager/issues/351)): when a page's better videos need ffmpeg and it isn't installed, the window now says so.diff --git a/ROADMAP.md b/ROADMAP.mdindex bce43069..5269508d 100644--- a/ROADMAP.md+++ b/ROADMAP.md@@ -457,6 +457,8 @@ These ship in a later version, when they're ready.### Bugs being looked into+- π A crash when removing the last feed in the RSS feeds window+ ([#321](https://github.com/anefzaoui/misterdownloadmanager/issues/321)): fix in review- π **Open folder** on a torrent still downloading([#354](https://github.com/anefzaoui/misterdownloadmanager/issues/354)): fix in review- π Alt and F10 opening the menu bar with a control focuseddiff --git a/crates/app/src/rssdlg.rs b/crates/app/src/rssdlg.rsindex 1378093d..44d7587b 100644--- a/crates/app/src/rssdlg.rs+++ b/crates/app/src/rssdlg.rs@@ -12,6 +12,7 @@ use crate::rss::{Article, Rule, Store};use crate::winui::{self, ButtonKind, r, text};/// What the window asks of the app.+#[derive(Debug, PartialEq, Eq)]pub enum Act {/// The store changed: save it.Saved,@@ -257,6 +258,7 @@ impl RssWindow {self.articles = Default::default();act = Some(Act::Saved);}+ let sel = self.feeds.selected.filter(|i| *i < store.feeds.len());// The selected feed's articles.let articles: Vec<Article> = sel.map(|i| store.feeds[i].articles.clone())@@ -780,3 +782,101 @@ impl RssWindow {if changed { Some(Act::Saved) } else { act }}}++#[cfg(test)]+mod tests {+ use super::*;+ use crate::rss::Parsed;++ /// #321: removing a feed in the RSS feeds window (including the last one) updates the+ /// selection for the rest of the frame instead of indexing `store.feeds` with the old row.+ #[test]+ fn removing_a_feed_including_the_last_one_does_not_panic() {+ let mut store = Store::default();+ let first = store.add_feed("https://a.example/rss.xml").unwrap();+ let second = store.add_feed("https://b.example/rss.xml").unwrap();+ store.fetched(+ first,+ Parsed {+ title: "First".into(),+ articles: vec![Article {+ id: "1".into(),+ title: "One".into(),+ torrent: "magnet:?xt=urn:btih:1".into(),+ ..Default::default()+ }],+ },+ 100,+ );+ store.fetched(+ second,+ Parsed {+ title: "Second".into(),+ articles: vec![Article {+ id: "2".into(),+ title: "Two".into(),+ torrent: "magnet:?xt=urn:btih:2".into(),+ ..Default::default()+ }],+ },+ 100,+ );++ let ctx = egui::Context::default();+ let mut defs = egui::FontDefinitions::default();+ winui::install_fonts(&mut defs, None);+ ctx.set_fonts(defs);++ let mut win = RssWindow::new(&store, false);+ let busy = HashSet::new();+ let remove_at = pos2(196.0, 424.0);+ let click_remove = |win: &mut RssWindow, store: &mut Store| -> Option<Act> {+ let mut run = |events: Vec<egui::Event>, store: &mut Store| -> Option<Act> {+ let mut act = None;+ let input = egui::RawInput {+ screen_rect: Some(egui::Rect::from_min_size(+ Pos2::ZERO,+ egui::vec2(760.0, 500.0),+ )),+ events,+ ..Default::default()+ };+ let mut out = ctx.run_ui(input, |ui| {+ act = win.feeds_page(ui, Pos2::ZERO, store, &busy);+ });+ out.textures_delta.clear();+ act+ };+ run(vec![egui::Event::PointerMoved(remove_at)], store);+ run(+ vec![egui::Event::PointerButton {+ pos: remove_at,+ button: egui::PointerButton::Primary,+ pressed: true,+ modifiers: egui::Modifiers::NONE,+ }],+ store,+ );+ run(+ vec![egui::Event::PointerButton {+ pos: remove_at,+ button: egui::PointerButton::Primary,+ pressed: false,+ modifiers: egui::Modifiers::NONE,+ }],+ store,+ )+ };++ // Removing the first of two feeds selects the remaining one without indexing out of bounds.+ assert_eq!(click_remove(&mut win, &mut store), Some(Act::Saved));+ assert_eq!(store.feeds.len(), 1);+ assert_eq!(store.feeds[0].id, second);+ assert_eq!(win.feeds.selected, Some(0));++ // Removing the last (only) feed leaves no selection and does not panic (#321).+ assert_eq!(click_remove(&mut win, &mut store), Some(Act::Saved));+ assert!(store.feeds.is_empty());+ assert_eq!(win.feeds.selected, None);+ }+}