chore: small fixes

This commit is contained in:
2025-03-11 13:22:44 +07:00
parent b92d446184
commit 8156d9d046
4 changed files with 178 additions and 196 deletions

View File

@@ -265,8 +265,7 @@ impl Device {
// Fetch user's metadata
let metadata = client
.fetch_metadata(public_key, Duration::from_secs(2))
.await
.unwrap_or_default()
.await?
.unwrap_or_default();
// Get user's inbox relays
@@ -693,6 +692,11 @@ impl Device {
});
cx.spawn_in(window, |_, mut cx| async move {
// No need to update if device keys are already available
if get_device_keys().await.is_some() {
return;
}
if let Err(e) = task.await {
cx.update(|window, cx| {
window.push_notification(
@@ -821,7 +825,7 @@ impl Device {
this.keyboard(false)
.closable(false)
.width(px(420.))
.width(px(430.))
.title("Your Messaging Relays are not configured")
.child(relays.clone())
.footer(
@@ -857,7 +861,7 @@ impl Device {
this.keyboard(false)
.closable(false)
.width(px(420.))
.width(px(430.))
.child(
div()
.flex()

View File

@@ -235,6 +235,89 @@ impl Render for Onboarding {
)
.child(div().w_72().w_full().flex().flex_col().gap_2().map(|this| {
match self.open {
PageKind::Connect => this
.when_some(self.connect_url.read(cx).as_ref(), |this, path| {
this.child(
div()
.mb_2()
.p_2()
.size_72()
.flex()
.flex_col()
.items_center()
.justify_center()
.gap_2()
.rounded_lg()
.shadow_md()
.when(cx.theme().appearance.is_dark(), |this| {
this.shadow_none().border_1().border_color(
cx.theme().base.step(cx, ColorScaleStep::SIX),
)
})
.bg(cx.theme().background)
.child(img(path.as_path()).h_64()),
)
})
.child(
div()
.text_xs()
.text_center()
.font_semibold()
.line_height(relative(1.2))
.child("Scan this QR to connect"),
)
.child(
Button::new("wait_for_connection")
.label("Waiting for connection")
.primary()
.w_full()
.loading(true)
.disabled(true),
)
.child(
Button::new("use_url")
.label("Use Bunker URL")
.custom(
ButtonCustomVariant::new(window, cx)
.color(
cx.theme().base.step(cx, ColorScaleStep::THREE),
)
.border(
cx.theme().base.step(cx, ColorScaleStep::THREE),
)
.hover(
cx.theme().base.step(cx, ColorScaleStep::FOUR),
)
.active(
cx.theme().base.step(cx, ColorScaleStep::FIVE),
)
.foreground(
cx.theme()
.base
.step(cx, ColorScaleStep::TWELVE),
),
)
.w_full()
.on_click(cx.listener(move |this, _, window, cx| {
this.open(PageKind::Bunker, window, cx);
})),
)
.child(
div()
.my_2()
.w_full()
.h_px()
.bg(cx.theme().base.step(cx, ColorScaleStep::THREE)),
)
.child(
Button::new("cancel")
.label("Cancel")
.ghost()
.w_full()
.on_click(cx.listener(move |this, _, window, cx| {
this.open(PageKind::Selection, window, cx);
})),
),
PageKind::Bunker => this
.child(
div()
@@ -270,108 +353,6 @@ impl Render for Onboarding {
this.connect(window, cx);
})),
)
.child(
Button::new("use_url")
.label("Get Connection URL")
.custom(
ButtonCustomVariant::new(window, cx)
.color(
cx.theme().base.step(cx, ColorScaleStep::THREE),
)
.border(
cx.theme().base.step(cx, ColorScaleStep::THREE),
)
.hover(
cx.theme().base.step(cx, ColorScaleStep::FOUR),
)
.active(
cx.theme().base.step(cx, ColorScaleStep::FIVE),
)
.foreground(
cx.theme()
.base
.step(cx, ColorScaleStep::TWELVE),
),
)
.w_full()
.on_click(cx.listener(move |this, _, window, cx| {
this.wait_for_connection(window, cx);
})),
)
.child(
div()
.my_2()
.w_full()
.h_px()
.bg(cx.theme().base.step(cx, ColorScaleStep::THREE)),
)
.child(
Button::new("cancel")
.label("Cancel")
.ghost()
.w_full()
.on_click(cx.listener(move |this, _, window, cx| {
this.open(PageKind::Selection, window, cx);
})),
),
PageKind::Connect => this
.when_some(self.connect_url.read(cx).as_ref(), |this, path| {
this.child(
div()
.mb_2()
.p_2()
.size_72()
.flex()
.flex_col()
.items_center()
.justify_center()
.gap_2()
.rounded_lg()
.shadow_md()
.when(cx.theme().appearance.is_dark(), |this| {
this.shadow_none().border_1().border_color(
cx.theme().base.step(cx, ColorScaleStep::SIX),
)
})
.bg(cx.theme().background)
.child(img(path.as_path()).h_64()),
)
})
.child(
div()
.text_xs()
.text_center()
.font_semibold()
.line_height(relative(1.2))
.child("Scan this QR to connect"),
)
.child(
Button::new("wait_for_connection")
.label("Waiting for connection")
.custom(
ButtonCustomVariant::new(window, cx)
.color(
cx.theme().base.step(cx, ColorScaleStep::THREE),
)
.border(
cx.theme().base.step(cx, ColorScaleStep::THREE),
)
.hover(
cx.theme().base.step(cx, ColorScaleStep::FOUR),
)
.active(
cx.theme().base.step(cx, ColorScaleStep::FIVE),
)
.foreground(
cx.theme()
.base
.step(cx, ColorScaleStep::TWELVE),
),
)
.w_full()
.loading(true)
.disabled(true),
)
.child(
div()
.my_2()
@@ -395,7 +376,7 @@ impl Render for Onboarding {
.primary()
.w_full()
.on_click(cx.listener(move |this, _, window, cx| {
this.open(PageKind::Bunker, window, cx);
this.wait_for_connection(window, cx);
})),
)
.child(

View File

@@ -221,8 +221,7 @@ impl Compose {
let metadata = client
.fetch_metadata(public_key, Duration::from_secs(2))
.await
.unwrap_or_default()
.await?
.unwrap_or_default();
Ok(NostrProfile::new(public_key, metadata))
@@ -237,8 +236,7 @@ impl Compose {
cx.background_spawn(async move {
let metadata = client
.fetch_metadata(public_key, Duration::from_secs(2))
.await
.unwrap_or_default()
.await?
.unwrap_or_default();
Ok(NostrProfile::new(public_key, metadata))