feat: nostr based auto updater (#200)
* . * refactor * fix * . * clean up * clean up
This commit is contained in:
@@ -13,6 +13,7 @@ actions!(sidebar, [Reload, RelayStatus]);
|
||||
pub struct CoopAuthUrlHandler;
|
||||
|
||||
impl AuthUrlHandler for CoopAuthUrlHandler {
|
||||
#[allow(mismatched_lifetime_syntaxes)]
|
||||
fn on_auth_url(&self, auth_url: Url) -> BoxedFuture<Result<()>> {
|
||||
Box::pin(async move {
|
||||
log::info!("Received Auth URL: {auth_url}");
|
||||
|
||||
@@ -4,7 +4,7 @@ use std::sync::Arc;
|
||||
|
||||
use account::Account;
|
||||
use anyhow::{anyhow, Error};
|
||||
use auto_update::AutoUpdater;
|
||||
use auto_update::{AutoUpdateStatus, AutoUpdater};
|
||||
use chat::{ChatEvent, ChatRegistry};
|
||||
use chat_ui::{CopyPublicKey, OpenPublicKey};
|
||||
use common::display::{shorten_pubkey, RenderedProfile};
|
||||
@@ -1166,12 +1166,43 @@ impl ChatSpace {
|
||||
fn titlebar_right(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||
let file_keystore = KeyStore::global(cx).read(cx).is_using_file_keystore();
|
||||
let proxy = AppSettings::get_proxy_user_avatars(cx);
|
||||
let updating = AutoUpdater::read_global(cx).status.is_updating();
|
||||
let updated = AutoUpdater::read_global(cx).status.is_updated();
|
||||
let auth_requests = self.auth_requests.read(cx).len();
|
||||
|
||||
h_flex()
|
||||
.gap_1()
|
||||
.map(
|
||||
|this| match AutoUpdater::global(cx).read(cx).status.as_ref() {
|
||||
AutoUpdateStatus::Checking => this.child(
|
||||
div()
|
||||
.text_xs()
|
||||
.text_color(cx.theme().text_muted)
|
||||
.child(SharedString::from("Checking for Coop updates...")),
|
||||
),
|
||||
AutoUpdateStatus::Installing => this.child(
|
||||
div()
|
||||
.text_xs()
|
||||
.text_color(cx.theme().text_muted)
|
||||
.child(SharedString::from("Installing updates...")),
|
||||
),
|
||||
AutoUpdateStatus::Errored { msg } => this.child(
|
||||
div()
|
||||
.text_xs()
|
||||
.text_color(cx.theme().text_muted)
|
||||
.child(SharedString::from(msg.as_ref())),
|
||||
),
|
||||
AutoUpdateStatus::Updated => this.child(
|
||||
div()
|
||||
.id("restart")
|
||||
.text_xs()
|
||||
.text_color(cx.theme().text_muted)
|
||||
.child(SharedString::from("Updated. Click to restart"))
|
||||
.on_click(|_ev, _window, cx| {
|
||||
cx.restart();
|
||||
}),
|
||||
),
|
||||
_ => this.child(div()),
|
||||
},
|
||||
)
|
||||
.when(file_keystore, |this| {
|
||||
this.child(
|
||||
Button::new("keystore-warning")
|
||||
@@ -1185,38 +1216,6 @@ impl ChatSpace {
|
||||
}),
|
||||
)
|
||||
})
|
||||
.when(updating, |this| {
|
||||
this.child(
|
||||
h_flex()
|
||||
.h_6()
|
||||
.px_2()
|
||||
.items_center()
|
||||
.justify_center()
|
||||
.text_xs()
|
||||
.rounded_full()
|
||||
.bg(cx.theme().ghost_element_background_alt)
|
||||
.child(shared_t!("auto_update.updating")),
|
||||
)
|
||||
})
|
||||
.when(updated, |this| {
|
||||
this.child(
|
||||
h_flex()
|
||||
.id("updated")
|
||||
.h_6()
|
||||
.px_2()
|
||||
.items_center()
|
||||
.justify_center()
|
||||
.text_xs()
|
||||
.rounded_full()
|
||||
.bg(cx.theme().ghost_element_background_alt)
|
||||
.hover(|this| this.bg(cx.theme().ghost_element_hover))
|
||||
.active(|this| this.bg(cx.theme().ghost_element_active))
|
||||
.child(shared_t!("auto_update.updated"))
|
||||
.on_click(|_, _window, cx| {
|
||||
cx.restart();
|
||||
}),
|
||||
)
|
||||
})
|
||||
.when(auth_requests > 0, |this| {
|
||||
this.child(
|
||||
h_flex()
|
||||
|
||||
Reference in New Issue
Block a user