Add windows nightly update banner (#42576)
Hopefully this will nudge some of the beta users who were on nightly to get on the official stable builds now that they're out. Release Notes: - N/A
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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(|_| {}) {
|
||||
|
||||
Reference in New Issue
Block a user