Skip to content

Commit

Permalink
fix(image_picker): Fix displaying filepaths
Browse files Browse the repository at this point in the history
Avoid calling FilelistCache::get on filepaths, as they won't be cached.
  • Loading branch information
danyspin97 committed Jun 28, 2024
1 parent 8570438 commit 8d4181c
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions daemon/src/image_picker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use log::warn;
use smithay_client_toolkit::reexports::client::{protocol::wl_surface::WlSurface, QueueHandle};

use crate::{
filelist_cache::FilelistCache,
filelist_cache::{self, FilelistCache},
wallpaper_groups::{WallpaperGroup, WallpaperGroups},
wallpaper_info::{Sorting, WallpaperInfo},
wpaperd::Wpaperd,
Expand Down Expand Up @@ -146,8 +146,8 @@ impl ImagePickerSorting {
fn new(
wallpaper_info: &WallpaperInfo,
wl_surface: &WlSurface,
files_len: usize,
groups: Rc<RefCell<WallpaperGroups>>,
filelist_cache: Rc<RefCell<FilelistCache>>,
) -> Self {
match wallpaper_info.sorting {
None | Some(Sorting::Random) => {
Expand All @@ -159,7 +159,14 @@ impl ImagePickerSorting {
wl_surface,
wallpaper_info.drawn_images_queue_size,
),
Some(Sorting::Ascending) => Self::new_ascending(files_len),
Some(Sorting::Ascending) => {
let files_len = filelist_cache
.clone()
.borrow()
.get(&wallpaper_info.path)
.len();
Self::new_ascending(files_len)
}
Some(Sorting::Descending) => Self::new_descending(),
}
}
Expand Down Expand Up @@ -215,12 +222,8 @@ impl ImagePicker {
sorting: ImagePickerSorting::new(
wallpaper_info,
wl_surface,
filelist_cache
.clone()
.borrow()
.get(&wallpaper_info.path)
.len(),
groups,
filelist_cache.clone(),
),
filelist_cache,
reload: false,
Expand Down

0 comments on commit 8d4181c

Please sign in to comment.