summaryrefslogtreecommitdiffstats
path: root/src/config/mod.rs
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2024-03-27 08:23:24 +0800
committerGitHub <noreply@github.com>2024-03-27 08:23:24 +0800
commita05c46253125a92a9c071e7310835dec2a06c0fc (patch)
tree725fe5508b7ab28fc1410382234ebecafdd4bf2c /src/config/mod.rs
parent3180d1d48573a6e12bb955ea0f6a312f80020fe6 (diff)
downloadaichat-a05c46253125a92a9c071e7310835dec2a06c0fc.tar.gz
fix: not dirty session when updating properties (#379)
Diffstat (limited to 'src/config/mod.rs')
-rw-r--r--src/config/mod.rs12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/config/mod.rs b/src/config/mod.rs
index 02eb64b..0254365 100644
--- a/src/config/mod.rs
+++ b/src/config/mod.rs
@@ -361,10 +361,11 @@ impl Config {
}
}
- pub fn set_compress_threshold(&mut self, value: usize) {
- self.compress_threshold = value;
+ pub fn set_compress_threshold(&mut self, value: Option<usize>) {
if let Some(session) = self.session.as_mut() {
session.set_compress_threshold(value);
+ } else {
+ self.compress_threshold = value.unwrap_or_default();
}
}
@@ -561,7 +562,12 @@ impl Config {
self.set_temperature(value);
}
"compress_threshold" => {
- let value = value.parse().with_context(|| "Invalid value")?;
+ let value = if unset {
+ None
+ } else {
+ let value = value.parse().with_context(|| "Invalid value")?;
+ Some(value)
+ };
self.set_compress_threshold(value);
}
"save" => {