Skip to content

Commit

Permalink
Show release notes locally when showing update notification (#18486)
Browse files Browse the repository at this point in the history
Closes #17527

I think we are ok to switch to using the local action now. There are a
few things we don't support, like media, but we don't include media
directly too often, and I think this might help push the community to
maybe add support for it. That being said, I updated the markdown coming
back from the endpoint to include links to the web version of the
release notes, so they can always hop over to that version, if they
would like.


https://github.com/user-attachments/assets/b4d207a7-1640-48f1-91d0-94537f74116c

All forming of the Markdown happens in the endpoint, so if someone with
a better eye wants to update this, you can do that here:


https://github.com/zed-industries/zed.dev/blob/0e5923e3e7d1caa8b4bf32d0a7f8999b34dbe64c/src/pages/api/release_notes/v2/%5Bchannel_type%5D/%5Bversion%5D.ts#L50-L62

Release Notes:

- Changed the `view the release notes` button in the update toast to
trigger the local release notes action.
  • Loading branch information
JosephTLyons authored Sep 28, 2024
1 parent 675673e commit 1021f0e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
12 changes: 7 additions & 5 deletions crates/auto_update/src/auto_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,15 +345,17 @@ pub fn notify_of_any_new_update(cx: &mut ViewContext<Workspace>) -> Option<()> {
let should_show_notification = should_show_notification.await?;
if should_show_notification {
workspace.update(&mut cx, |workspace, cx| {
let workspace_handle = workspace.weak_handle();
workspace.show_notification(
NotificationId::unique::<UpdateNotification>(),
cx,
|cx| cx.new_view(|_| UpdateNotification::new(version)),
|cx| cx.new_view(|_| UpdateNotification::new(version, workspace_handle)),
);
updater
.read(cx)
.set_should_show_update_notification(false, cx)
.detach_and_log_err(cx);
updater.update(cx, |updater, cx| {
updater
.set_should_show_update_notification(false, cx)
.detach_and_log_err(cx);
});
})?;
}
anyhow::Ok(())
Expand Down
19 changes: 14 additions & 5 deletions crates/auto_update/src/update_notification.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
use gpui::{
div, DismissEvent, EventEmitter, InteractiveElement, IntoElement, ParentElement, Render,
SemanticVersion, StatefulInteractiveElement, Styled, ViewContext,
SemanticVersion, StatefulInteractiveElement, Styled, ViewContext, WeakView,
};
use menu::Cancel;
use release_channel::ReleaseChannel;
use workspace::ui::{h_flex, v_flex, Icon, IconName, Label, StyledExt};
use util::ResultExt;
use workspace::{
ui::{h_flex, v_flex, Icon, IconName, Label, StyledExt},
Workspace,
};

pub struct UpdateNotification {
version: SemanticVersion,
workspace: WeakView<Workspace>,
}

impl EventEmitter<DismissEvent> for UpdateNotification {}
Expand Down Expand Up @@ -41,16 +46,20 @@ impl Render for UpdateNotification {
.child(Label::new("View the release notes"))
.cursor_pointer()
.on_click(cx.listener(|this, _, cx| {
crate::view_release_notes(&Default::default(), cx);
this.workspace
.update(cx, |workspace, cx| {
crate::view_release_notes_locally(workspace, cx);
})
.log_err();
this.dismiss(&menu::Cancel, cx)
})),
)
}
}

impl UpdateNotification {
pub fn new(version: SemanticVersion) -> Self {
Self { version }
pub fn new(version: SemanticVersion, workspace: WeakView<Workspace>) -> Self {
Self { version, workspace }
}

pub fn dismiss(&mut self, _: &Cancel, cx: &mut ViewContext<Self>) {
Expand Down

0 comments on commit 1021f0e

Please sign in to comment.