Merge branch 'main' into welcome

This commit is contained in:
Mikayla 2023-11-27 18:51:19 -08:00
commit 8faa1f6e58
No known key found for this signature in database
188 changed files with 6979 additions and 6715 deletions

View file

@ -16,7 +16,7 @@ path = "src/main.rs"
[dependencies]
ai = { package = "ai2", path = "../ai2"}
# audio = { path = "../audio" }
audio = { package = "audio2", path = "../audio2" }
# activity_indicator = { path = "../activity_indicator" }
auto_update = { package = "auto_update2", path = "../auto_update2" }
# breadcrumbs = { path = "../breadcrumbs" }

View file

@ -71,7 +71,11 @@ fn main() {
log::info!("========== starting zed ==========");
let app = App::production(Arc::new(Assets));
let installation_id = app.background_executor().block(installation_id()).ok();
let (installation_id, existing_installation_id_found) = app
.background_executor()
.block(installation_id())
.ok()
.unzip();
let session_id = Uuid::new_v4().to_string();
init_panic_hook(&app, installation_id.clone(), session_id.clone());
@ -172,6 +176,14 @@ fn main() {
// .detach();
client.telemetry().start(installation_id, session_id, cx);
let telemetry_settings = *client::TelemetrySettings::get_global(cx);
let event_operation = match existing_installation_id_found {
Some(false) => "first open",
_ => "open",
};
client
.telemetry()
.report_app_event(telemetry_settings, event_operation);
let app_state = Arc::new(AppState {
languages,
@ -179,12 +191,13 @@ fn main() {
user_store,
fs,
build_window_options,
call_factory: call::Call::new,
workspace_store,
node_runtime,
});
cx.set_global(Arc::downgrade(&app_state));
// audio::init(Assets, cx);
audio::init(Assets, cx);
auto_update::init(http.clone(), client::ZED_SERVER_URL.clone(), cx);
workspace::init(app_state.clone(), cx);
@ -331,11 +344,11 @@ async fn authenticate(client: Arc<Client>, cx: &AsyncAppContext) -> Result<()> {
Ok::<_, anyhow::Error>(())
}
async fn installation_id() -> Result<String> {
async fn installation_id() -> Result<(String, bool)> {
let legacy_key_name = "device_id";
if let Ok(Some(installation_id)) = KEY_VALUE_STORE.read_kvp(legacy_key_name) {
Ok(installation_id)
Ok((installation_id, true))
} else {
let installation_id = Uuid::new_v4().to_string();
@ -343,7 +356,7 @@ async fn installation_id() -> Result<String> {
.write_kvp(legacy_key_name.to_string(), installation_id.clone())
.await?;
Ok(installation_id)
Ok((installation_id, false))
}
}

View file

@ -166,12 +166,17 @@ pub fn initialize_workspace(app_state: Arc<AppState>, cx: &mut AppContext) {
// vim::observe_keystrokes(cx);
// cx.on_window_should_close(|workspace, cx| {
// if let Some(task) = workspace.close(&Default::default(), cx) {
// task.detach_and_log_err(cx);
// }
// false
// });
let handle = cx.view().downgrade();
cx.on_window_should_close(move |cx| {
handle
.update(cx, |workspace, cx| {
if let Some(task) = workspace.close(&Default::default(), cx) {
task.detach_and_log_err(cx);
}
false
})
.unwrap_or(true)
});
cx.spawn(|workspace_handle, mut cx| async move {
let project_panel = ProjectPanel::load(workspace_handle.clone(), cx.clone());