diff --git a/crates/zed/Cargo.toml b/crates/zed/Cargo.toml index 1ccfe8d1f5f60f825072f5034f629296f1229269..547855ec8f54ec8970a7470088bcc824a0a98148 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.rs index cbd6fba694136c87c64c4d6ca2bfee6d1e1072dd..49f1206caeaaba2d54f5084de025ba7bb70f310d 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::(), 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) { if let Err(e) = fs::fs_watcher::global(|_| {}) {