Skip to content

Commit

Permalink
Update internal chat::List if chat title changes
Browse files Browse the repository at this point in the history
  • Loading branch information
hecrj committed Jul 27, 2024
1 parent 860061c commit 60f7a69
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/data/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,18 @@ impl Chat {
title: Option<String>,
history: Vec<Message>,
) -> Result<Self, Error> {
let current = Self::fetch(id.clone()).await?;

if current.title != title {
let mut list = List::fetch().await?;

if let Some(entry) = list.entries.iter_mut().find(|entry| entry.id == id) {
entry.title = title.clone();
}

list.save().await?;
}

let chat = Schema {
id,
file,
Expand Down

0 comments on commit 60f7a69

Please sign in to comment.