Add event for welcome page close

This commit is contained in:
Joseph T. Lyons 2024-01-06 15:17:28 -05:00
parent cdd5cb16ed
commit 167a0b590f
2 changed files with 13 additions and 42 deletions

View File

@ -866,7 +866,6 @@ impl Item for Editor {
}
fn to_item_events(event: &EditorEvent, mut f: impl FnMut(ItemEvent)) {
dbg!(event);
match event {
EditorEvent::Closed => f(ItemEvent::CloseItem),

View File

@ -14,7 +14,7 @@ use ui::{prelude::*, Checkbox};
use vim::VimModeSetting;
use workspace::{
dock::DockPosition,
item::{Item, ItemEvent, ItemHandle},
item::{Item, ItemEvent},
open_new, AppState, Welcome, Workspace, WorkspaceId,
};
@ -252,48 +252,20 @@ impl Render for WelcomePage {
impl WelcomePage {
pub fn new(workspace: &Workspace, cx: &mut ViewContext<Workspace>) -> View<Self> {
let this = cx.new_view(|cx| WelcomePage {
focus_handle: cx.focus_handle(),
workspace: workspace.weak_handle(),
telemetry: workspace.client().telemetry().clone(),
_settings_subscription: cx.observe_global::<SettingsStore>(move |_, cx| cx.notify()),
});
let this = cx.new_view(|cx| {
cx.on_release(|this: &mut Self, _, _| {
this.telemetry.report_app_event("close welcome page", false);
})
.detach();
this.on_release(
cx,
Box::new(|cx| {
this.update(cx, |this, _| {
this.telemetry.report_app_event("close welcome page", false);
})
}),
)
.detach();
// this.subscribe_to_item_events(
// cx,
// Box::new(|event: ItemEvent, cx| {
// // if event == ItemEvent::CloseItem {
// dbg!(event);
// // welcome.update(cx, |welcome, _| {
// // welcome
// // .telemetry
// // .report_app_event("close welcome page", false);
// // })
// // }
// }),
// )
// .detach();
cx.subscribe(&this, |_, welcome, event, cx| {
if *event == ItemEvent::CloseItem {
welcome.update(cx, |welcome, _| {
welcome
.telemetry
.report_app_event("close welcome page", false);
})
WelcomePage {
focus_handle: cx.focus_handle(),
workspace: workspace.weak_handle(),
telemetry: workspace.client().telemetry().clone(),
_settings_subscription: cx
.observe_global::<SettingsStore>(move |_, cx| cx.notify()),
}
})
.detach();
});
this
}