Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Add windows nightly update banner (#42576)
Julia Ryan15ab96af6bc1
diff --git a/crates/zed/Cargo.toml b/crates/zed/Cargo.tomlindex 1ccfe8d1f5f..547855ec8f5 100644--- a/crates/zed/Cargo.toml+++ b/crates/zed/Cargo.toml@@ -171,6 +171,7 @@ chrono.workspace = true[target.'cfg(target_os = "windows")'.dependencies]windows.workspace = true+chrono.workspace = true[target.'cfg(target_os = "windows")'.build-dependencies]winresource = "0.1"diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rsindex cbd6fba6941..49f1206caea 100644--- a/crates/zed/src/zed.rs+++ b/crates/zed/src/zed.rs@@ -393,6 +393,9 @@ pub fn initialize_workspace(}}+ #[cfg(target_os = "windows")]+ unstable_version_notification(cx);+let edit_prediction_menu_handle = PopoverMenuHandle::default();let edit_prediction_button = cx.new(|cx| {edit_prediction_button::EditPredictionButton::new(@@ -471,6 +474,53 @@ pub fn initialize_workspace(.detach();}+#[cfg(target_os = "windows")]+fn unstable_version_notification(cx: &mut App) {+ if !matches!(+ ReleaseChannel::try_global(cx),+ Some(ReleaseChannel::Nightly)+ ) {+ return;+ }+ let db_key = "zed_windows_nightly_notif_shown_at".to_owned();+ let time = chrono::Utc::now();+ if let Some(last_shown) = db::kvp::KEY_VALUE_STORE+ .read_kvp(&db_key)+ .log_err()+ .flatten()+ .and_then(|timestamp| chrono::DateTime::parse_from_rfc3339(×tamp).ok())+ {+ if time.fixed_offset() - last_shown < chrono::Duration::days(7) {+ return;+ }+ }+ cx.spawn(async move |_| {+ db::kvp::KEY_VALUE_STORE+ .write_kvp(db_key, time.to_rfc3339())+ .await+ })+ .detach_and_log_err(cx);+ struct WindowsNightly;+ show_app_notification(NotificationId::unique::<WindowsNightly>(), cx, |cx| {+ cx.new(|cx| {+ MessageNotification::new("You're using an unstable version of Zed (Nightly)", cx)+ .primary_message("Download Stable")+ .primary_icon_color(Color::Accent)+ .primary_icon(IconName::Download)+ .primary_on_click(|window, cx| {+ window.dispatch_action(+ zed_actions::OpenBrowser {+ url: "https://zed.dev/download".to_string(),+ }+ .boxed_clone(),+ cx,+ );+ cx.emit(DismissEvent);+ })+ })+ });+}+#[cfg(any(target_os = "linux", target_os = "freebsd"))]fn initialize_file_watcher(window: &mut Window, cx: &mut Context<Workspace>) {if let Err(e) = fs::fs_watcher::global(|_| {}) {