Clean up view_release_notes()
This commit is contained in:
parent
0a0921f88b
commit
7c5fdb3a44
2 changed files with 19 additions and 15 deletions
|
@ -93,7 +93,9 @@ pub fn init(http_client: Arc<dyn HttpClient>, server_url: String, cx: &mut AppCo
|
||||||
cx.observe_new_views(|workspace: &mut Workspace, _cx| {
|
cx.observe_new_views(|workspace: &mut Workspace, _cx| {
|
||||||
workspace.register_action(|_, action: &Check, cx| check(action, cx));
|
workspace.register_action(|_, action: &Check, cx| check(action, cx));
|
||||||
|
|
||||||
workspace.register_action(|_, action, cx| view_release_notes(action, cx));
|
workspace.register_action(|_, action, cx| {
|
||||||
|
view_release_notes(action, cx);
|
||||||
|
});
|
||||||
|
|
||||||
// @nate - code to trigger update notification on launch
|
// @nate - code to trigger update notification on launch
|
||||||
// todo!("remove this when Nate is done")
|
// todo!("remove this when Nate is done")
|
||||||
|
@ -140,23 +142,23 @@ pub fn check(_: &Check, cx: &mut WindowContext) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn view_release_notes(_: &ViewReleaseNotes, cx: &mut AppContext) {
|
pub fn view_release_notes(_: &ViewReleaseNotes, cx: &mut AppContext) -> Option<()> {
|
||||||
if let Some(auto_updater) = AutoUpdater::get(cx) {
|
let auto_updater = AutoUpdater::get(cx)?;
|
||||||
|
let release_channel = cx.try_global::<ReleaseChannel>()?;
|
||||||
|
|
||||||
|
if matches!(
|
||||||
|
release_channel,
|
||||||
|
ReleaseChannel::Stable | ReleaseChannel::Preview
|
||||||
|
) {
|
||||||
let auto_updater = auto_updater.read(cx);
|
let auto_updater = auto_updater.read(cx);
|
||||||
let server_url = &auto_updater.server_url;
|
let server_url = &auto_updater.server_url;
|
||||||
|
let release_channel = release_channel.dev_name();
|
||||||
let current_version = auto_updater.current_version;
|
let current_version = auto_updater.current_version;
|
||||||
|
let url = format!("{server_url}/releases/{release_channel}/{current_version}");
|
||||||
if let Some(release_channel) = cx.try_global::<ReleaseChannel>() {
|
cx.open_url(&url);
|
||||||
let channel = match release_channel {
|
|
||||||
ReleaseChannel::Preview => "preview",
|
|
||||||
ReleaseChannel::Stable => "stable",
|
|
||||||
_ => return,
|
|
||||||
};
|
|
||||||
cx.open_url(&format!(
|
|
||||||
"{server_url}/releases/{channel}/{current_version}"
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn notify_of_any_new_update(cx: &mut ViewContext<Workspace>) -> Option<()> {
|
pub fn notify_of_any_new_update(cx: &mut ViewContext<Workspace>) -> Option<()> {
|
||||||
|
|
|
@ -40,7 +40,9 @@ impl Render for UpdateNotification {
|
||||||
.id("notes")
|
.id("notes")
|
||||||
.child(Label::new("View the release notes"))
|
.child(Label::new("View the release notes"))
|
||||||
.cursor_pointer()
|
.cursor_pointer()
|
||||||
.on_click(|_, cx| crate::view_release_notes(&Default::default(), cx)),
|
.on_click(|_, cx| {
|
||||||
|
crate::view_release_notes(&Default::default(), cx);
|
||||||
|
}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue