uds ipc working
This commit is contained in:
23
src/app.rs
23
src/app.rs
@ -28,8 +28,14 @@ impl App {
|
||||
let mut list_state = ListState::default();
|
||||
list_state.select(Some(0));
|
||||
|
||||
let items = ipc::fetch_history(100)
|
||||
.unwrap_or_else(|| vec!["rklipd deamon unaccessible".to_string()]);
|
||||
let items = ipc::fetch_history(100).unwrap_or_default();
|
||||
|
||||
let mut list_state = ListState::default();
|
||||
if items.is_empty() {
|
||||
list_state.select(None);
|
||||
} else {
|
||||
list_state.select(Some(0));
|
||||
}
|
||||
|
||||
let picker = Picker::from_query_stdio().unwrap_or_else(|_| Picker::halfblocks());
|
||||
|
||||
@ -175,6 +181,17 @@ impl App {
|
||||
}
|
||||
|
||||
pub fn get_selected_item(&self) -> Option<&String> {
|
||||
self.list_state.selected().map(|i| &self.filtered_items[i])
|
||||
self.list_state
|
||||
.selected()
|
||||
.and_then(|i| self.filtered_items.get(i))
|
||||
}
|
||||
|
||||
pub fn sync_with_daemon(&mut self) {
|
||||
if let Some(new_history) = crate::ipc::fetch_history(100) {
|
||||
if self.all_items != new_history {
|
||||
self.all_items = new_history;
|
||||
self.update_search();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user