|
|
|
@ -1,4 +1,7 @@
|
|
|
|
|
use std::{sync::mpsc::{self, Receiver, Sender}, time::Duration};
|
|
|
|
|
use std::{
|
|
|
|
|
sync::mpsc::{self, Receiver, Sender},
|
|
|
|
|
time::Duration,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
use chrono::Local;
|
|
|
|
|
use eframe::{
|
|
|
|
@ -131,35 +134,31 @@ impl eframe::App for App {
|
|
|
|
|
ScrollArea::vertical()
|
|
|
|
|
.id_source("history_scroll")
|
|
|
|
|
.show(ui, |ui| {
|
|
|
|
|
Grid::new("history_grid").num_columns(1).show(
|
|
|
|
|
ui,
|
|
|
|
|
|ui| {
|
|
|
|
|
for entry in &self.history {
|
|
|
|
|
let response = ui
|
|
|
|
|
.horizontal(|ui| {
|
|
|
|
|
ui.label(&entry.selected_ai);
|
|
|
|
|
ui.label(
|
|
|
|
|
entry
|
|
|
|
|
.date
|
|
|
|
|
.format("%Y-%m-%d %H:%M:%S")
|
|
|
|
|
.to_string(),
|
|
|
|
|
)
|
|
|
|
|
})
|
|
|
|
|
.response;
|
|
|
|
|
|
|
|
|
|
let clickable =
|
|
|
|
|
ui.allocate_rect(response.rect, Sense::click());
|
|
|
|
|
|
|
|
|
|
if clickable.clicked() {
|
|
|
|
|
self.open_history_entry = Some(entry.clone());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ui.end_row()
|
|
|
|
|
Grid::new("history_grid").num_columns(1).show(ui, |ui| {
|
|
|
|
|
for entry in &self.history {
|
|
|
|
|
let response = ui
|
|
|
|
|
.horizontal(|ui| {
|
|
|
|
|
ui.label(&entry.selected_ai);
|
|
|
|
|
ui.label(
|
|
|
|
|
entry
|
|
|
|
|
.date
|
|
|
|
|
.format("%Y-%m-%d %H:%M:%S")
|
|
|
|
|
.to_string(),
|
|
|
|
|
)
|
|
|
|
|
})
|
|
|
|
|
.response;
|
|
|
|
|
|
|
|
|
|
let clickable =
|
|
|
|
|
ui.allocate_rect(response.rect, Sense::click());
|
|
|
|
|
|
|
|
|
|
if clickable.clicked() {
|
|
|
|
|
self.open_history_entry = Some(entry.clone());
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
ui.end_row()
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -199,8 +198,12 @@ impl eframe::App for App {
|
|
|
|
|
ui.with_layout(Layout::right_to_left(Align::Max), |ui| {
|
|
|
|
|
ui.add_visible_ui(CONFIG.app.history_dir.is_some(), |ui| {
|
|
|
|
|
if ui.button("History").clicked() {
|
|
|
|
|
// add proper error handling
|
|
|
|
|
self.history = read_all_history().unwrap();
|
|
|
|
|
match read_all_history() {
|
|
|
|
|
Ok(history) => self.history = history,
|
|
|
|
|
Err(error) => {
|
|
|
|
|
self.toasts.error(error.to_string());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
self.history_open = true;
|
|
|
|
|
}
|
|
|
|
|