Fix todos in auto-update
This commit is contained in:
parent
b95cc7221c
commit
ead5206741
2 changed files with 10 additions and 15 deletions
|
@ -9,12 +9,14 @@ use gpui::{
|
||||||
ViewContext, VisualContext,
|
ViewContext, VisualContext,
|
||||||
};
|
};
|
||||||
use isahc::AsyncBody;
|
use isahc::AsyncBody;
|
||||||
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde_derive::Serialize;
|
use serde_derive::Serialize;
|
||||||
use smol::io::AsyncReadExt;
|
use smol::io::AsyncReadExt;
|
||||||
|
|
||||||
use settings::{Settings, SettingsStore};
|
use settings::{Settings, SettingsStore};
|
||||||
use smol::{fs::File, process::Command};
|
use smol::{fs::File, process::Command};
|
||||||
|
|
||||||
use std::{ffi::OsString, sync::Arc, time::Duration};
|
use std::{ffi::OsString, sync::Arc, time::Duration};
|
||||||
use update_notification::UpdateNotification;
|
use update_notification::UpdateNotification;
|
||||||
use util::channel::{AppCommitSha, ReleaseChannel};
|
use util::channel::{AppCommitSha, ReleaseChannel};
|
||||||
|
@ -24,16 +26,7 @@ use workspace::Workspace;
|
||||||
const SHOULD_SHOW_UPDATE_NOTIFICATION_KEY: &str = "auto-updater-should-show-updated-notification";
|
const SHOULD_SHOW_UPDATE_NOTIFICATION_KEY: &str = "auto-updater-should-show-updated-notification";
|
||||||
const POLL_INTERVAL: Duration = Duration::from_secs(60 * 60);
|
const POLL_INTERVAL: Duration = Duration::from_secs(60 * 60);
|
||||||
|
|
||||||
//todo!(remove CheckThatAutoUpdaterWorks)
|
actions!(auto_update, [Check, DismissErrorMessage, ViewReleaseNotes]);
|
||||||
actions!(
|
|
||||||
auto_update,
|
|
||||||
[
|
|
||||||
Check,
|
|
||||||
DismissErrorMessage,
|
|
||||||
ViewReleaseNotes,
|
|
||||||
CheckThatAutoUpdaterWorks
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
struct UpdateRequestBody {
|
struct UpdateRequestBody {
|
||||||
|
@ -90,7 +83,10 @@ 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));
|
||||||
|
|
||||||
// @nate - code to trigger update notification on launch
|
// @nate - code to trigger update notification on launch
|
||||||
|
// todo!("remove this when Nate is done")
|
||||||
// workspace.show_notification(0, _cx, |cx| {
|
// workspace.show_notification(0, _cx, |cx| {
|
||||||
// cx.build_view(|_| UpdateNotification::new(SemanticVersion::from_str("1.1.1").unwrap()))
|
// cx.build_view(|_| UpdateNotification::new(SemanticVersion::from_str("1.1.1").unwrap()))
|
||||||
// });
|
// });
|
||||||
|
@ -119,9 +115,6 @@ pub fn init(http_client: Arc<dyn HttpClient>, server_url: String, cx: &mut AppCo
|
||||||
updater
|
updater
|
||||||
});
|
});
|
||||||
cx.set_global(Some(auto_updater));
|
cx.set_global(Some(auto_updater));
|
||||||
//todo!(action)
|
|
||||||
// cx.add_global_action(view_release_notes);
|
|
||||||
// cx.add_action(UpdateNotification::dismiss);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ use gpui::{
|
||||||
div, DismissEvent, Div, EventEmitter, InteractiveElement, ParentElement, Render,
|
div, DismissEvent, Div, EventEmitter, InteractiveElement, ParentElement, Render,
|
||||||
SemanticVersion, StatefulInteractiveElement, Styled, ViewContext,
|
SemanticVersion, StatefulInteractiveElement, Styled, ViewContext,
|
||||||
};
|
};
|
||||||
|
use menu::Cancel;
|
||||||
use util::channel::ReleaseChannel;
|
use util::channel::ReleaseChannel;
|
||||||
use workspace::ui::{h_stack, v_stack, Icon, IconElement, Label, StyledExt};
|
use workspace::ui::{h_stack, v_stack, Icon, IconElement, Label, StyledExt};
|
||||||
|
|
||||||
|
@ -18,6 +19,7 @@ impl Render for UpdateNotification {
|
||||||
let app_name = cx.global::<ReleaseChannel>().display_name();
|
let app_name = cx.global::<ReleaseChannel>().display_name();
|
||||||
|
|
||||||
v_stack()
|
v_stack()
|
||||||
|
.on_action(cx.listener(UpdateNotification::dismiss))
|
||||||
.elevation_3(cx)
|
.elevation_3(cx)
|
||||||
.p_4()
|
.p_4()
|
||||||
.child(
|
.child(
|
||||||
|
@ -32,7 +34,7 @@ impl Render for UpdateNotification {
|
||||||
.id("cancel")
|
.id("cancel")
|
||||||
.child(IconElement::new(Icon::Close))
|
.child(IconElement::new(Icon::Close))
|
||||||
.cursor_pointer()
|
.cursor_pointer()
|
||||||
.on_click(cx.listener(|this, _, cx| this.dismiss(cx))),
|
.on_click(cx.listener(|this, _, cx| this.dismiss(&menu::Cancel, cx))),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
|
@ -50,7 +52,7 @@ impl UpdateNotification {
|
||||||
Self { version }
|
Self { version }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dismiss(&mut self, cx: &mut ViewContext<Self>) {
|
pub fn dismiss(&mut self, _: &Cancel, cx: &mut ViewContext<Self>) {
|
||||||
cx.emit(DismissEvent);
|
cx.emit(DismissEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue