summaryrefslogtreecommitdiff
path: root/src/watch.rs
diff options
context:
space:
mode:
authormo8it <mo8it@proton.me>2024-04-14 01:15:43 +0200
committermo8it <mo8it@proton.me>2024-04-14 01:15:43 +0200
commit5c0073a9485c4226e58b657cb49628919a28a942 (patch)
tree00cd8cb2ca8926e5e6cf68e44d51d14f77cc4695 /src/watch.rs
parent2a26dfcb005d2a9ee24e920462b37dfb6d235c32 (diff)
Tolerate changes in the state file
Diffstat (limited to 'src/watch.rs')
-rw-r--r--src/watch.rs15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/watch.rs b/src/watch.rs
index beb69b3..58e829f 100644
--- a/src/watch.rs
+++ b/src/watch.rs
@@ -11,14 +11,14 @@ use std::{
time::Duration,
};
-mod debounce_event;
+mod notify_event;
mod state;
mod terminal_event;
use crate::app_state::{AppState, ExercisesProgress};
use self::{
- debounce_event::DebounceEventHandler,
+ notify_event::DebounceEventHandler,
state::WatchState,
terminal_event::{terminal_event_handler, InputEvent},
};
@@ -40,13 +40,16 @@ pub enum WatchExit {
List,
}
-pub fn watch(app_state: &mut AppState) -> Result<WatchExit> {
+pub fn watch(
+ app_state: &mut AppState,
+ exercise_paths: &'static [&'static Path],
+) -> Result<WatchExit> {
let (tx, rx) = channel();
let mut debouncer = new_debouncer(
Duration::from_secs(1),
DebounceEventHandler {
tx: tx.clone(),
- exercises: app_state.exercises(),
+ exercise_paths,
},
)?;
debouncer
@@ -85,10 +88,10 @@ pub fn watch(app_state: &mut AppState) -> Result<WatchExit> {
watch_state.render()?;
}
WatchEvent::NotifyErr(e) => {
- return Err(Error::from(e).context("Exercise file watcher failed"))
+ return Err(Error::from(e).context("Exercise file watcher failed"));
}
WatchEvent::TerminalEventErr(e) => {
- return Err(Error::from(e).context("Terminal event listener failed"))
+ return Err(Error::from(e).context("Terminal event listener failed"));
}
}
}