mirror of
https://github.com/storytold/lightcraft.git
synced 2026-10-27 19:47:35 -06:00
Drop a removed folder from the filter Enable Filters put aside
This commit is contained in:
@@ -470,6 +470,15 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
if s.filter.library_folder.as_deref().is_some_and(|c| lightcraft_catalog::query::folder_within(c, path)) {
|
||||
s.filter.library_folder = None;
|
||||
}
|
||||
// a filter put aside by Enable Filters must not bring the removed folder back
|
||||
if let Some(f) = s.shelved_filter.as_mut()
|
||||
&& f.library_folder.as_deref().is_some_and(|c| lightcraft_catalog::query::folder_within(c, path))
|
||||
{
|
||||
f.library_folder = None;
|
||||
}
|
||||
if s.shelved_filter.as_ref() == Some(&Filter::default()) {
|
||||
s.shelved_filter = None;
|
||||
}
|
||||
// the folder being shown is gone: back to everything, as for a deleted album
|
||||
if s.library_folder.as_deref().is_some_and(|c| lightcraft_catalog::query::folder_within(c, path)) {
|
||||
s.library_folder = None;
|
||||
|
||||
@@ -116,3 +116,23 @@ fn a_folder_filter_does_not_come_back_over_the_folder_now_shown() {
|
||||
assert_eq!(s.filter.rating, 4);
|
||||
assert_eq!(s.filter.library_folder, None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn removing_a_folder_while_off_drops_it_from_the_filter_put_aside() {
|
||||
let mut s = session().unwrap();
|
||||
s.execute("library.filter", &json!({"rating": 4, "libraryFolder": "/lightcraft-enable-filters"})).unwrap();
|
||||
s.execute("library.toggleFilters", &json!({})).unwrap();
|
||||
s.execute("library.removeFolder", &json!({"path": "/lightcraft-enable-filters"})).unwrap();
|
||||
s.execute("library.toggleFilters", &json!({})).unwrap();
|
||||
assert_eq!(s.filter.library_folder, None, "the removed folder is not brought back");
|
||||
assert_eq!(s.filter.rating, 4, "the rest of the filter is");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn removing_the_only_criterion_put_aside_leaves_filtering_on() {
|
||||
let mut s = session().unwrap();
|
||||
s.execute("library.filter", &json!({"libraryFolder": "/lightcraft-enable-filters"})).unwrap();
|
||||
s.execute("library.toggleFilters", &json!({})).unwrap();
|
||||
s.execute("library.removeFolder", &json!({"path": "/lightcraft-enable-filters"})).unwrap();
|
||||
assert!(s.shelved_filter.is_none(), "an empty filter is not left put aside");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user