diff options
author | Jeff Zhao <jeff.no.zhao@gmail.com> | 2022-08-31 11:11:06 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-31 11:11:06 -0400 |
commit | 0ca4ffd657f1a2884ca8422be8a78baa42f00de4 (patch) | |
tree | 408c91b138707942b4c7736893e4ecbefbe9a544 /src/event | |
parent | cd838711107303e4c6076df5bc38b2b74c819480 (diff) |
use hashmap and uuid to store tabs (#194)
This is preliminary changes in order to track preview threads and progress.
The current setup is we just kick off a new thread to load
the given directory whenever we see the directory content
does not exist in history.
We don't track these threads or which tab these requests
came from. When the result is returned, we just assign it
to the current tab, instead of the tab that actually
initiated the request.
By adding uuid, we can now track which tab requested the
preview and assign it accordingly.
This will also allow us to track the status of the preview,
so we can display to the user a loading state,
when a directory is taking longer than usual to load.
This will also solve the problem of kicking off multiple
threads to read the same directory for the same tab.
Now these threads can be stored and tracked.
- side: fix reload not honouring tab sort options
- use tab specific options whenever we need to reload stuff
Diffstat (limited to 'src/event')
-rw-r--r-- | src/event/process_event.rs | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/src/event/process_event.rs b/src/event/process_event.rs index 0857daa..446b98c 100644 --- a/src/event/process_event.rs +++ b/src/event/process_event.rs @@ -70,7 +70,7 @@ pub fn process_noninteractive(event: AppEvent, context: &mut AppContext) { } fn process_filesystem_event(_event: notify::Event, context: &mut AppContext) { - let _ = reload::soft_reload(context.tab_context_ref().index, context); + let _ = reload::soft_reload_curr_tab(context); } pub fn process_new_worker(context: &mut AppContext) { @@ -92,28 +92,23 @@ pub fn process_finished_worker( let worker_context = context.worker_context_mut(); let observer = worker_context.remove_worker().unwrap(); let options = context.config_ref().display_options_ref().clone(); - let tab_options = context - .tab_context_ref() - .curr_tab_ref() - .option_ref() - .clone(); - for tab in context.tab_context_mut().iter_mut() { - let _ = tab - .history_mut() - .reload(observer.dest_path(), &options, &tab_options); - let _ = tab - .history_mut() - .reload(observer.src_path(), &options, &tab_options); - } - - /* delete - // remove directory previews - for tab in context.tab_context_mut().iter_mut() { - for p in &paths { - tab.history_mut().remove(p.as_path()); + for (_, tab) in context.tab_context_mut().iter_mut() { + let tab_options = tab.option_ref().clone(); + if observer.dest_path().exists() { + let _ = tab + .history_mut() + .reload(observer.dest_path(), &options, &tab_options); + } else { + tab.history_mut().remove(observer.dest_path()); + } + if observer.src_path().exists() { + let _ = tab + .history_mut() + .reload(observer.src_path(), &options, &tab_options); + } else { + tab.history_mut().remove(observer.src_path()); } } - */ observer.join(); match res { |