formatting pass
This commit is contained in:
1 parent
d976eebbbc
commit
e4cfa53bce
21 files changed
+333
-194
No files matched your search
+17
-19
@@ -1,6 +1,6 @@
|
||||
use gpui_kit::{
|
||||
AppContext, Context, Entity, FontWeight, IntoElement, ParentElement, Render, SharedString,
|
||||
Styled, Subscription, Task,Window, div, rems,
|
||||
Styled, Subscription, Task, Window, div, rems,
|
||||
};
|
||||
use gpui_omarchy::{ActiveTheme, ButtonVariant, button, focus_scope};
|
||||
|
||||
@@ -9,10 +9,8 @@ use crate::config::AppConfig;
|
||||
use crate::db::Db;
|
||||
use crate::session::AppSession;
|
||||
|
||||
|
||||
const MISMATCH: &str = "Passphrases do not match.";
|
||||
|
||||
|
||||
/// First-run screen: choose a passphrase, derive the key, and unlock the session.
|
||||
pub struct WelcomeScreen {
|
||||
passphrase: Entity<PassphraseInput>,
|
||||
@@ -38,17 +36,19 @@ impl WelcomeScreen {
|
||||
|
||||
let mut _subscriptions = Vec::new();
|
||||
for input in [&passphrase, &confirm] {
|
||||
_subscriptions.push(cx.subscribe_in(input, window, |this, _, event, window, cx| {
|
||||
match event {
|
||||
PassphraseInputEvent::Submit => this.submit(window, cx),
|
||||
// typing only dismisses the mismatch error, never raises it
|
||||
PassphraseInputEvent::Change if this.passphrases_match(cx) => {
|
||||
this.error = None;
|
||||
cx.notify();
|
||||
_subscriptions.push(
|
||||
cx.subscribe_in(input, window, |this, _, event, window, cx| {
|
||||
match event {
|
||||
PassphraseInputEvent::Submit => this.submit(window, cx),
|
||||
// typing only dismisses the mismatch error, never raises it
|
||||
PassphraseInputEvent::Change if this.passphrases_match(cx) => {
|
||||
this.error = None;
|
||||
cx.notify();
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}));
|
||||
}),
|
||||
);
|
||||
}
|
||||
// leaving the confirm field is what raises the mismatch error
|
||||
_subscriptions.push(cx.subscribe_in(&confirm, window, |this, _, event, _, cx| {
|
||||
@@ -96,9 +96,7 @@ impl WelcomeScreen {
|
||||
self.pending = Some(cx.spawn(async move |this, cx| {
|
||||
// argon2 is deliberately slow, so keep it off the UI thread
|
||||
let result = cx
|
||||
.background_spawn(async move {
|
||||
Db::connect(&config, passphrase.as_str())
|
||||
})
|
||||
.background_spawn(async move { Db::connect(&config, passphrase.as_str()) })
|
||||
.await;
|
||||
|
||||
let _ = this.update(cx, |this, cx| {
|
||||
@@ -174,9 +172,9 @@ impl Render for WelcomeScreen {
|
||||
.child(
|
||||
button("submit", "Submit", ButtonVariant::Primary, cx)
|
||||
.disabled(self.pending.is_some())
|
||||
.on_click(cx.listener(|this, _, window, cx| {
|
||||
this.submit(window, cx)
|
||||
})),
|
||||
.on_click(
|
||||
cx.listener(|this, _, window, cx| this.submit(window, cx)),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user