Skip to content

Commit

Permalink
delete chat new chat
Browse files Browse the repository at this point in the history
  • Loading branch information
ddxfish committed Sep 7, 2024
1 parent f106867 commit 5fcb99f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rust_chatbot_ui"
version = "0.4.2"
version = "0.4.5"
edition = "2021"

[dependencies]
Expand Down
4 changes: 2 additions & 2 deletions settings.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[Settings]
ui_scale=2
theme=0
theme=3
ui_scale=1.95

6 changes: 3 additions & 3 deletions src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ impl ChatbotApp {
self.ui.selected_provider = self.providers[0].name().to_string();
self.ui.selected_model = self.providers[0].models()[0].to_string();
self.chat.update_provider(Arc::clone(&self.providers[0]));
if let Err(e) = self.chat.create_new_chat() {
eprintln!("Failed to create new chat: {}", e);
}
// if let Err(e) = self.chat.create_new_chat() {
// eprintln!("Failed to create new chat: {}", e);
// }
}

fn change_ui_scale(&mut self, ctx: &egui::Context, increase: bool) {
Expand Down
7 changes: 7 additions & 0 deletions src/ui/message_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::collections::HashMap;

pub struct MessageView {
cache: HashMap<usize, CachedMessage>,
current_theme: String,
}

struct CachedMessage {
Expand All @@ -19,10 +20,16 @@ impl MessageView {
pub fn new() -> Self {
Self {
cache: HashMap::new(),
current_theme: String::new(),
}
}

pub fn render_messages(&mut self, ui: &mut Ui, chat: &Chat, current_response: &str, is_loading: bool, theme: &Theme) {
if self.current_theme != theme.name {
self.cache.clear();
self.current_theme = theme.name.clone();
}

let mut scroll_to_bottom = false;
ScrollArea::vertical()
.auto_shrink([false; 2])
Expand Down

0 comments on commit 5fcb99f

Please sign in to comment.