mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-11 21:13:02 +00:00
Add a confirmation prompt
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
This commit is contained in:
parent
e928c1c61e
commit
35524db136
1 changed files with 17 additions and 7 deletions
|
@ -1,22 +1,22 @@
|
||||||
use std::{mem, sync::Arc};
|
|
||||||
|
|
||||||
use crate::contacts_popover;
|
use crate::contacts_popover;
|
||||||
use call::ActiveCall;
|
use call::ActiveCall;
|
||||||
use client::{proto::PeerId, Contact, User, UserStore};
|
use client::{proto::PeerId, Contact, User, UserStore};
|
||||||
use editor::{Cancel, Editor};
|
use editor::{Cancel, Editor};
|
||||||
|
use futures::StreamExt;
|
||||||
use fuzzy::{match_strings, StringMatchCandidate};
|
use fuzzy::{match_strings, StringMatchCandidate};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
elements::*,
|
elements::*,
|
||||||
geometry::{rect::RectF, vector::vec2f},
|
geometry::{rect::RectF, vector::vec2f},
|
||||||
impl_actions, impl_internal_actions,
|
impl_actions, impl_internal_actions,
|
||||||
keymap_matcher::KeymapContext,
|
keymap_matcher::KeymapContext,
|
||||||
AppContext, CursorStyle, Entity, ModelHandle, MouseButton, MutableAppContext, RenderContext,
|
AppContext, CursorStyle, Entity, ModelHandle, MouseButton, MutableAppContext, PromptLevel,
|
||||||
Subscription, View, ViewContext, ViewHandle,
|
RenderContext, Subscription, View, ViewContext, ViewHandle,
|
||||||
};
|
};
|
||||||
use menu::{Confirm, SelectNext, SelectPrev};
|
use menu::{Confirm, SelectNext, SelectPrev};
|
||||||
use project::Project;
|
use project::Project;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
|
use std::{mem, sync::Arc};
|
||||||
use theme::IconButton;
|
use theme::IconButton;
|
||||||
use util::ResultExt;
|
use util::ResultExt;
|
||||||
use workspace::{JoinProject, OpenSharedScreen};
|
use workspace::{JoinProject, OpenSharedScreen};
|
||||||
|
@ -299,8 +299,18 @@ impl ContactList {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn remove_contact(&mut self, request: &RemoveContact, cx: &mut ViewContext<Self>) {
|
fn remove_contact(&mut self, request: &RemoveContact, cx: &mut ViewContext<Self>) {
|
||||||
self.user_store
|
let user_id = request.0;
|
||||||
.update(cx, |store, cx| store.remove_contact(request.0, cx))
|
let user_store = self.user_store.clone();
|
||||||
|
let prompt_message = "Are you sure you want to remove this contact?";
|
||||||
|
let mut answer = cx.prompt(PromptLevel::Warning, prompt_message, &["Remove", "Cancel"]);
|
||||||
|
cx.spawn(|_, mut cx| async move {
|
||||||
|
if answer.next().await == Some(0) {
|
||||||
|
user_store
|
||||||
|
.update(&mut cx, |store, cx| store.remove_contact(user_id, cx))
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
})
|
||||||
.detach();
|
.detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue