fix(resurrection): some ui fixes (#3264)
This commit is contained in:
parent
ee9aae789c
commit
5441309c5c
2 changed files with 41 additions and 21 deletions
|
|
@ -21,6 +21,9 @@ impl ResurrectableSessions {
|
||||||
pub fn update(&mut self, mut list: Vec<(String, Duration)>) {
|
pub fn update(&mut self, mut list: Vec<(String, Duration)>) {
|
||||||
list.sort_by(|a, b| a.1.cmp(&b.1));
|
list.sort_by(|a, b| a.1.cmp(&b.1));
|
||||||
self.all_resurrectable_sessions = list;
|
self.all_resurrectable_sessions = list;
|
||||||
|
if self.is_searching {
|
||||||
|
self.update_search_term();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pub fn render(&self, rows: usize, columns: usize, x: usize, y: usize) {
|
pub fn render(&self, rows: usize, columns: usize, x: usize, y: usize) {
|
||||||
if self.delete_all_dead_sessions_warning {
|
if self.delete_all_dead_sessions_warning {
|
||||||
|
|
@ -256,6 +259,11 @@ impl ResurrectableSessions {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn delete_selected_session(&mut self) {
|
pub fn delete_selected_session(&mut self) {
|
||||||
|
if self.is_searching {
|
||||||
|
self.selected_search_index
|
||||||
|
.and_then(|i| self.search_results.get(i))
|
||||||
|
.map(|search_result| delete_dead_session(&search_result.session_name));
|
||||||
|
} else {
|
||||||
self.selected_index
|
self.selected_index
|
||||||
.and_then(|i| {
|
.and_then(|i| {
|
||||||
if self.all_resurrectable_sessions.len() > i {
|
if self.all_resurrectable_sessions.len() > i {
|
||||||
|
|
@ -274,6 +282,7 @@ impl ResurrectableSessions {
|
||||||
delete_dead_session(&session_name_and_creation_time.0)
|
delete_dead_session(&session_name_and_creation_time.0)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
fn delete_all_sessions(&mut self) {
|
fn delete_all_sessions(&mut self) {
|
||||||
// optimistic update
|
// optimistic update
|
||||||
self.all_resurrectable_sessions = vec![];
|
self.all_resurrectable_sessions = vec![];
|
||||||
|
|
@ -319,7 +328,18 @@ impl ResurrectableSessions {
|
||||||
matches.sort_by(|a, b| b.score.cmp(&a.score));
|
matches.sort_by(|a, b| b.score.cmp(&a.score));
|
||||||
self.search_results = matches;
|
self.search_results = matches;
|
||||||
self.is_searching = !self.search_term.is_empty();
|
self.is_searching = !self.search_term.is_empty();
|
||||||
|
match self.selected_search_index {
|
||||||
|
Some(search_index) => {
|
||||||
|
if self.search_results.is_empty() {
|
||||||
|
self.selected_search_index = None;
|
||||||
|
} else if search_index >= self.search_results.len() {
|
||||||
|
self.selected_search_index = Some(self.search_results.len().saturating_sub(1));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
None => {
|
||||||
self.selected_search_index = Some(0);
|
self.selected_search_index = Some(0);
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -436,10 +436,10 @@ fn find_resurrectable_sessions(
|
||||||
{
|
{
|
||||||
Ok(created) => Some(created),
|
Ok(created) => Some(created),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
if e.kind() != std::io::ErrorKind::NotFound {
|
if e.kind() == std::io::ErrorKind::NotFound {
|
||||||
// let's not spam the
|
return None; // no layout file, cannot resurrect session, let's not
|
||||||
// logs if serialization
|
// list it
|
||||||
// is disabled
|
} else {
|
||||||
log::error!(
|
log::error!(
|
||||||
"Failed to read created stamp of resurrection file: {:?}",
|
"Failed to read created stamp of resurrection file: {:?}",
|
||||||
e
|
e
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue