Fix divide by 0 in terminal

Fix fail to remove contact in contact list
This commit is contained in:
Mikayla Maki 2023-03-16 12:31:50 -07:00
parent 1fbdea6a03
commit c3325430ca
2 changed files with 13 additions and 2 deletions

View file

@ -316,12 +316,20 @@ impl ContactList {
github_login
);
let mut answer = cx.prompt(PromptLevel::Warning, &prompt_message, &["Remove", "Cancel"]);
let window_id = cx.window_id();
cx.spawn(|_, mut cx| async move {
if answer.next().await == Some(0) {
user_store
if let Err(e) = user_store
.update(&mut cx, |store, cx| store.remove_contact(user_id, cx))
.await
.unwrap();
{
cx.prompt(
window_id,
PromptLevel::Info,
&format!("Failed to remove contact: {}", e),
&["Ok"],
);
}
}
})
.detach();