@@ -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(())
@@ -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 {}
@@ -41,7 +46,11 @@ 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)
})),
)
@@ -49,8 +58,8 @@ impl Render for UpdateNotification {
}
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>) {