From 0670a6f838e0d869b8607e5f3dd605373cdd68ff Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Fri, 5 Jan 2024 16:32:47 +0100 Subject: [PATCH] Fix up warnings, bind 'Done' button to DismissEvent --- crates/copilot_button/src/copilot_button.rs | 8 +++++--- crates/copilot_button/src/sign_in.rs | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/crates/copilot_button/src/copilot_button.rs b/crates/copilot_button/src/copilot_button.rs index 6bf1d6cfcc..2a1bde785e 100644 --- a/crates/copilot_button/src/copilot_button.rs +++ b/crates/copilot_button/src/copilot_button.rs @@ -376,9 +376,11 @@ fn initiate_sign_in(cx: &mut WindowContext) { } _ => { copilot.update(cx, |this, cx| this.sign_in(cx)).detach(); - workspace.update(cx, |this, cx| { - this.toggle_modal(cx, |cx| CopilotCodeVerification::new(&copilot, cx)); - }); + workspace + .update(cx, |this, cx| { + this.toggle_modal(cx, |cx| CopilotCodeVerification::new(&copilot, cx)); + }) + .ok(); } } } diff --git a/crates/copilot_button/src/sign_in.rs b/crates/copilot_button/src/sign_in.rs index 15e68f961e..d3e52c3e19 100644 --- a/crates/copilot_button/src/sign_in.rs +++ b/crates/copilot_button/src/sign_in.rs @@ -1,17 +1,14 @@ use copilot::{request::PromptUserDeviceFlow, Copilot, Status}; use gpui::{ - div, size, svg, AppContext, Bounds, ClipboardItem, DismissEvent, Element, EventEmitter, - FocusHandle, FocusableView, GlobalPixels, InteractiveElement, IntoElement, Model, - ParentElement, Point, Render, Styled, Subscription, ViewContext, VisualContext, WindowBounds, - WindowHandle, WindowKind, WindowOptions, + div, svg, AppContext, ClipboardItem, DismissEvent, Element, EventEmitter, FocusHandle, + FocusableView, InteractiveElement, IntoElement, Model, ParentElement, Render, Styled, + Subscription, ViewContext, }; use ui::{prelude::*, Button, Icon, Label}; use workspace::ModalView; const COPILOT_SIGN_UP_URL: &'static str = "https://github.com/features/copilot"; -pub fn init(cx: &mut AppContext) {} - pub struct CopilotCodeVerification { status: Status, connect_clicked: bool, @@ -20,7 +17,7 @@ pub struct CopilotCodeVerification { } impl FocusableView for CopilotCodeVerification { - fn focus_handle(&self, cx: &AppContext) -> gpui::FocusHandle { + fn focus_handle(&self, _: &AppContext) -> gpui::FocusHandle { self.focus_handle.clone() } } @@ -111,13 +108,16 @@ impl CopilotCodeVerification { .style(ButtonStyle::Filled), ) } - fn render_enabled_modal() -> impl Element { + fn render_enabled_modal(cx: &mut ViewContext) -> impl Element { v_stack() .child(Label::new("Copilot Enabled!")) .child(Label::new( "You can update your settings or sign out from the Copilot menu in the status bar.", )) - .child(Button::new("copilot-enabled-done-button", "Done").on_click(|_, cx| {})) + .child( + Button::new("copilot-enabled-done-button", "Done") + .on_click(cx.listener(|_, _, cx| cx.emit(DismissEvent))), + ) } fn render_unauthorized_modal() -> impl Element { @@ -148,7 +148,7 @@ impl Render for CopilotCodeVerification { } Status::Authorized => { self.connect_clicked = false; - Self::render_enabled_modal().into_any_element() + Self::render_enabled_modal(cx).into_any_element() } _ => div().into_any_element(), };