mirror of
https://github.com/storytold/lightcraft.git
synced 2026-10-27 11:37:13 -06:00
Recently Deleted shows deleted Local (browsed) photos (Fixes #1430)
A photo browsed in a Local folder is flagged deleted by photo.delete, but Filter::matches_in dropped every browsed photo from views without a folder, so it vanished from the folder and never reached Recently Deleted: it could not be restored and sat in the catalog invisibly (a deleted record is also never forgotten as an untouched Local one). Deleted browsed photos now match the Recently Deleted filter, so they can be restored; the library view still excludes browsed photos.
This commit is contained in:
@@ -251,8 +251,8 @@ impl Filter {
|
||||
return false;
|
||||
}
|
||||
match &self.folder {
|
||||
// browsed photos only show in folder views
|
||||
None if p.local => return false,
|
||||
// browsed photos only show in folder views, and in Recently Deleted once deleted (#1430)
|
||||
None if p.local && !p.deleted => return false,
|
||||
None => {}
|
||||
Some(dir) => {
|
||||
let crate::Source::File { path } = &p.source else { return false };
|
||||
|
||||
@@ -237,6 +237,23 @@ fn recently_deleted_shows_the_deleted_photos_of_the_chosen_folder() {
|
||||
assert!(!f.matches(c.photo(kept).unwrap(), &c));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_deleted_browsed_photo_shows_in_recently_deleted_and_comes_back() {
|
||||
let mut c = Catalog::new();
|
||||
let browsed = add_with(&mut c, "/pics/trip/a.jpg", |p| p.local = true);
|
||||
let recently_deleted = Filter { deleted: true, ..Default::default() };
|
||||
let library = Filter::default();
|
||||
assert!(!recently_deleted.matches(c.photo(browsed).unwrap(), &c));
|
||||
assert!(!library.matches(c.photo(browsed).unwrap(), &c), "browsed photos stay out of the library view");
|
||||
|
||||
c.apply(Op::SetDeleted { id: browsed, deleted: true }).unwrap();
|
||||
assert_eq!(c.query(&recently_deleted, &Sort::default()), vec![browsed], "#1430: it was invisible everywhere");
|
||||
assert!(c.query(&library, &Sort::default()).is_empty());
|
||||
|
||||
c.apply(Op::SetDeleted { id: browsed, deleted: false }).unwrap();
|
||||
assert!(c.query(&recently_deleted, &Sort::default()).is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_empty_folder_choice_is_no_choice() {
|
||||
let c = library(&["/pics/a.jpg"]);
|
||||
|
||||
Reference in New Issue
Block a user