wip
This commit is contained in:
@@ -11,6 +11,7 @@ serde.workspace = true
|
||||
serde_json.workspace = true
|
||||
futures.workspace = true
|
||||
|
||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||
gpui-updater-pre = "0.2"
|
||||
|
||||
[dev-dependencies]
|
||||
|
||||
@@ -6,6 +6,7 @@ use anyhow::{Error, anyhow};
|
||||
use browser_signer_proxy::prelude::*;
|
||||
use common::config_dir;
|
||||
use gpui::{App, AppContext, Context, Entity, EventEmitter, Global, Task, TaskExt};
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
use gpui_tokio::Tokio;
|
||||
use instant::Duration;
|
||||
use nostr_connect::prelude::*;
|
||||
|
||||
@@ -226,7 +226,6 @@ impl Render for ImportIdentity {
|
||||
const BUNKER_WARN: &str = "Nostr Connect will usually take more time to get all your messages. Please keep your session open until you see all your messages.";
|
||||
const KEY_WARN: &str = "Coop encrypts your key with your passphrase and stores it on this device. You only need the passphrase to sign in next time.";
|
||||
|
||||
let is_wasm = cfg!(target_arch = "wasm32");
|
||||
let is_unlock = self.mode == Mode::Unlock;
|
||||
|
||||
let value = self.key_input.read(cx).value().trim().to_string();
|
||||
@@ -305,26 +304,32 @@ impl Render for ImportIdentity {
|
||||
)
|
||||
}),
|
||||
)
|
||||
.child(
|
||||
Button::new("login")
|
||||
.label(if is_unlock { "Unlock" } else { "Continue" })
|
||||
.primary()
|
||||
.loading(self.loading)
|
||||
.disabled(self.loading)
|
||||
.on_click(cx.listener(move |this, _ev, _window, cx| {
|
||||
this.login(cx);
|
||||
})),
|
||||
)
|
||||
.when(!is_wasm && !is_unlock, |this| {
|
||||
this.child(
|
||||
Button::new("proxy")
|
||||
.label("Connect via Web Extension (Experimental)")
|
||||
.ghost()
|
||||
.child({
|
||||
let content = v_flex().child(
|
||||
Button::new("login")
|
||||
.label(if is_unlock { "Unlock" } else { "Continue" })
|
||||
.primary()
|
||||
.loading(self.loading)
|
||||
.disabled(self.loading)
|
||||
.on_click(cx.listener(move |this, _ev, _window, cx| {
|
||||
this.proxy(cx);
|
||||
this.login(cx);
|
||||
})),
|
||||
)
|
||||
);
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let content = content.when(!is_unlock, |this| {
|
||||
this.child(
|
||||
Button::new("proxy")
|
||||
.label("Connect via Web Extension (Experimental)")
|
||||
.ghost()
|
||||
.disabled(self.loading)
|
||||
.on_click(cx.listener(move |this, _ev, _window, cx| {
|
||||
this.proxy(cx);
|
||||
})),
|
||||
)
|
||||
});
|
||||
|
||||
content
|
||||
})
|
||||
.when_some(self.error.read(cx).as_ref(), |this, error| {
|
||||
this.child(
|
||||
|
||||
@@ -2,6 +2,7 @@ use std::sync::Arc;
|
||||
|
||||
use ::settings::{AppSettings, AppearanceMode};
|
||||
use anyhow::Error;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
use auto_update::AutoUpdater;
|
||||
use chat::{ChatEvent, ChatRegistry};
|
||||
use common::download_dir;
|
||||
@@ -372,7 +373,9 @@ impl Workspace {
|
||||
Command::ImportEncryption => {
|
||||
self.import_encryption(window, cx);
|
||||
}
|
||||
Command::Update => {
|
||||
Command::Update =>
|
||||
{
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
if let Some(auto_updater) = AutoUpdater::try_global(cx) {
|
||||
auto_updater.update(cx, |this, cx| this.check(cx));
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
use auto_update::AutoUpdater;
|
||||
use gpui::prelude::FluentBuilder;
|
||||
use gpui::{
|
||||
@@ -25,6 +26,7 @@ impl Sidebar {
|
||||
current_user: &PublicKey,
|
||||
cx: &mut Context<Self>,
|
||||
) -> Stateful<Div> {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let updater = AutoUpdater::try_global(cx);
|
||||
let profile = self.directory.read(cx).person(current_user, cx);
|
||||
let avatar = profile.avatar();
|
||||
@@ -62,12 +64,15 @@ impl Sidebar {
|
||||
)
|
||||
}),
|
||||
)
|
||||
.child(
|
||||
h_flex()
|
||||
.gap_1()
|
||||
.when_some(updater, |this, updater| {
|
||||
this.child(self.render_updater(updater, cx))
|
||||
})
|
||||
.child({
|
||||
let actions = h_flex().gap_1();
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let actions = actions.when_some(updater, |this, updater| {
|
||||
this.child(self.render_updater(updater, cx))
|
||||
});
|
||||
|
||||
actions
|
||||
.child(
|
||||
Button::new("sidebar-search")
|
||||
.icon(IconName::Search)
|
||||
@@ -104,8 +109,8 @@ impl Sidebar {
|
||||
this.hide_group(cx);
|
||||
})),
|
||||
)
|
||||
}),
|
||||
)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/// The bottom navigation, pinned below the list like signed's sidebar.
|
||||
@@ -128,6 +133,7 @@ impl Sidebar {
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
fn render_updater(&self, updater: Entity<AutoUpdater>, cx: &mut App) -> AnyElement {
|
||||
let status = updater.read(cx).status();
|
||||
let up_to_date = updater.read(cx).up_to_date();
|
||||
|
||||
Reference in New Issue
Block a user