Skip to content

Commit

Permalink
Avoid updating chat::List when new chat is created
Browse files Browse the repository at this point in the history
  • Loading branch information
hecrj committed Jul 30, 2024
1 parent e674908 commit ff6ba23
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/data/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,16 @@ impl Chat {
title: Option<String>,
history: Vec<Message>,
) -> Result<Self, Error> {
let current = Self::fetch(id.clone()).await?;
if let Ok(current) = Self::fetch(id.clone()).await {
if current.title != title {
let mut list = List::fetch().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();
}

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

list.save().await?;
}

let chat = Schema {
Expand Down

0 comments on commit ff6ba23

Please sign in to comment.