watch repo once loaded

[?]
Feb 23, 2025, 7:07 PM
KM5PSZ4A2FJOPHJA6RC7LHZAUXLQDZDQC2DVSE5YUORLFIPZO74QC

Dependencies

Change contents

  • edit in crates/flowers_ui/src/main.rs at line 40
    [3.581][4.515:516](),[4.516][6.5306:5344](),[6.5344][4.516:1242](),[4.516][4.516:1242](),[4.1242][5.1797:1882](),[5.1882][4.1308:1370](),[4.1308][4.1308:1370](),[4.1370][6.5345:5474](),[6.5474][4.1437:1438](),[4.1437][4.1437:1438]()
    // TODO: start watch once loaded?
    let (fs_watch_tx, fs_watch_rx) = watch::channel(());
    let mut fs_watch = new_debouncer(
    Duration::from_secs(1),
    None,
    move |result: DebounceEventResult| match result {
    Ok(events) => events.iter().for_each(|event| {
    // TODO: distinguish ".pijul" changes
    // dbg!(event);
    if event.kind.is_create()
    || event.kind.is_modify()
    || event.kind.is_remove()
    {
    let _ = fs_watch_tx.send(());
    }
    }),
    Err(errors) => {
    errors.iter().for_each(|error| eprintln!("{error:?}"))
    }
    },
    )
    .unwrap();
    fs_watch
    .watch(&repo_path, RecursiveMode::Recursive)
    .unwrap();
    let fs_watch_rx = WatchStream::from_changes(fs_watch_rx);
    let watch_task = Task::run(fs_watch_rx, |()| {
    Message::ToRepo(repo::MsgIn::RefreshChangedAndUntrackedFiles)
    });
  • edit in crates/flowers_ui/src/main.rs at line 44
    [6.5633]
    [6.5633]
    let repo_path_clone = repo_path.clone();
  • replacement in crates/flowers_ui/src/main.rs at line 46
    [6.5679][6.5679:5743]()
    repo::manage(repo_path, repo_rx_in, repo_tx_out).await;
    [6.5679]
    [6.5743]
    repo::manage(repo_path_clone, repo_rx_in, repo_tx_out).await;
  • replacement in crates/flowers_ui/src/main.rs at line 52
    [5.1997][6.5920:5993]()
    let tasks = Task::batch([watch_task, repo_task, repo_msg_out_task]);
    [5.1997]
    [4.1438]
    let tasks = Task::batch([repo_task, repo_msg_out_task]);
  • replacement in crates/flowers_ui/src/main.rs at line 55
    [4.1460][5.1998:2031]()
    _fs_watch: fs_watch,
    [4.1460]
    [6.5994]
    repo_fs_watch: None,
    repo_path,
  • replacement in crates/flowers_ui/src/main.rs at line 68
    [2.1363][5.2032:2096]()
    _fs_watch: Debouncer<RecommendedWatcher, RecommendedCache>,
    [2.1363]
    [6.6092]
    repo_fs_watch: Option<Debouncer<RecommendedWatcher, RecommendedCache>>,
    repo_path: PathBuf,
  • replacement in crates/flowers_ui/src/main.rs at line 341
    [6.14932][6.14932:14957]()
    Task::none()
    [6.14932]
    [6.14957]
    // Start watching the repo's dir for changes
    let (fs_watch_tx, fs_watch_rx) = watch::channel(());
    let mut fs_watch = new_debouncer(
    Duration::from_secs(1),
    None,
    move |result: DebounceEventResult| match result {
    Ok(events) => events.iter().for_each(|event| {
    // TODO: distinguish ".pijul" changes
    // dbg!(event);
    if event.kind.is_create()
    || event.kind.is_modify()
    || event.kind.is_remove()
    {
    let _ = fs_watch_tx.send(());
    }
    }),
    Err(errors) => {
    errors.iter().for_each(|error| eprintln!("{error:?}"))
    }
    },
    )
    .unwrap();
    fs_watch
    .watch(&state.repo_path, RecursiveMode::Recursive)
    .unwrap();
    let fs_watch_rx = WatchStream::from_changes(fs_watch_rx);
    let watch_task = Task::run(fs_watch_rx, |()| {
    Message::ToRepo(repo::MsgIn::RefreshChangedAndUntrackedFiles)
    });
    state.repo_fs_watch = Some(fs_watch);
    watch_task