Fix saved filters hiding all apps on startup (#678) (#684)

* #678: clear obsolete saved filters at desktop startup

* #678: share saved filter migration across startup paths

* #678: cover legacy saved filters and locale-safe UI startup
This commit is contained in:
skylar taylor-barrick
2026-10-20 12:46:55 -06:00
committed by GitHub
parent 046d48fb2a
commit a538251f1e
4 changed files with 60 additions and 6 deletions
+23 -1
View File
@@ -507,7 +507,7 @@ impl Launcher {
fn start(&mut self, settings: Option<Settings>, waker: &Arc<Waker>) {
self.started = true;
if let Some(settings) = settings {
self.ui.settings = settings;
self.restore_saved_settings(settings);
}
self.waker = Some(waker.clone());
let (wake, on_quit) = (waker.clone(), waker.clone());
@@ -518,6 +518,13 @@ impl Launcher {
self.host.tray = self.tray.is_some();
}
fn restore_saved_settings(&mut self, mut settings: Settings) {
// `LauncherUi::new` sees defaults before the shell loads persisted settings. Filters
// removed from the 0.6 toolbar must be cleared at this later load boundary too.
settings.migrate();
self.ui.settings = settings;
}
/// Readies the launcher for a new window. Unless the launcher started in the tray, the first
/// one brings the saved settings and the tray icon.
fn open(&mut self, cc: &eframe::CreationContext<'_>, waker: &Arc<Waker>) {
@@ -814,6 +821,21 @@ mod tests {
(Launcher::new(Box::new(Quiet(seen.clone())), show_requests, None), show, seen)
}
#[test]
fn saved_filters_are_migrated_when_desktop_settings_load() {
use artcraft_launcher_ui_egui::settings::Filter;
let (mut launcher, _show, _) = launcher();
// `start` also creates a native tray, which macOS requires on the main thread.
for (filter, expected) in
[(Filter::Installed, Filter::All), (Filter::Updates, Filter::All), (Filter::NotInstalled, Filter::All), (Filter::Hidden, Filter::Hidden)]
{
launcher.restore_saved_settings(Settings { filter, last_check: Some(NOW), ..Settings::default() });
assert_eq!(launcher.ui.settings.filter, expected, "{filter:?}");
assert_eq!(launcher.ui.settings.last_check, Some(NOW));
}
}
#[test]
fn a_wayland_window_cannot_hide() {
assert!(!window_can_hide(Some(RawDisplayHandle::Wayland(WaylandDisplayHandle::new(NonNull::dangling())))));