summaryrefslogtreecommitdiffstats
path: root/src/preview/preview_dir.rs
blob: b74e606622f2dc71f8b3e839ac1a5d3726e42ba5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use std::path;
use std::thread;

use crate::context::AppContext;
use crate::event::AppEvent;
use crate::fs::JoshutoDirList;

pub struct Background {}

impl Background {
    pub fn load_preview(context: &mut AppContext, p: path::PathBuf) -> thread::JoinHandle<()> {
        let event_tx = context.events.event_tx.clone();
        let options = context.config_ref().display_options_ref().clone();

        thread::spawn(move || {
            if let Ok(dirlist) = JoshutoDirList::from_path(p, &options) {
                let _ = event_tx.send(AppEvent::PreviewDir(Ok(Box::new(dirlist))));
            }
        })
    }
}