feat: refactor to use gpui event instead of local state #18
@@ -113,7 +113,7 @@ impl Workspace {
|
|||||||
let note = Notification::new()
|
let note = Notification::new()
|
||||||
.id::<RelayNotifcation>()
|
.id::<RelayNotifcation>()
|
||||||
.message("Connecting to the bootstrap relay...")
|
.message("Connecting to the bootstrap relay...")
|
||||||
.title("Relays")
|
.with_kind(NotificationKind::Info)
|
||||||
.icon(IconName::Relay);
|
.icon(IconName::Relay);
|
||||||
|
|
||||||
window.push_notification(note, cx);
|
window.push_notification(note, cx);
|
||||||
@@ -122,7 +122,6 @@ impl Workspace {
|
|||||||
let note = Notification::new()
|
let note = Notification::new()
|
||||||
.id::<RelayNotifcation>()
|
.id::<RelayNotifcation>()
|
||||||
.message("Connected to the bootstrap relay")
|
.message("Connected to the bootstrap relay")
|
||||||
.title("Relays")
|
|
||||||
.with_kind(NotificationKind::Success)
|
.with_kind(NotificationKind::Success)
|
||||||
.icon(IconName::Relay);
|
.icon(IconName::Relay);
|
||||||
|
|
||||||
@@ -555,13 +554,7 @@ impl Workspace {
|
|||||||
.id::<RelayNotifcation>()
|
.id::<RelayNotifcation>()
|
||||||
.icon(IconName::Relay)
|
.icon(IconName::Relay)
|
||||||
.title("Gossip Relays are required")
|
.title("Gossip Relays are required")
|
||||||
.content(move |_this, _window, cx| {
|
.message(BODY)
|
||||||
v_flex()
|
|
||||||
.text_sm()
|
|
||||||
.text_color(cx.theme().text_muted)
|
|
||||||
.child(SharedString::from(BODY))
|
|
||||||
.into_any_element()
|
|
||||||
})
|
|
||||||
.action(move |_this, _window, _cx| {
|
.action(move |_this, _window, _cx| {
|
||||||
let entity = entity.clone();
|
let entity = entity.clone();
|
||||||
let public_key = public_key.to_owned();
|
let public_key = public_key.to_owned();
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use std::time::Duration;
|
|||||||
use anyhow::{Context as AnyhowContext, Error, anyhow};
|
use anyhow::{Context as AnyhowContext, Error, anyhow};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
App, AppContext, Context, Entity, EventEmitter, Global, IntoElement, ParentElement,
|
App, AppContext, Context, Entity, EventEmitter, Global, IntoElement, ParentElement,
|
||||||
SharedString, Styled, Task, Window, div,
|
SharedString, Styled, Task, Window, div, relative,
|
||||||
};
|
};
|
||||||
use nostr_sdk::prelude::*;
|
use nostr_sdk::prelude::*;
|
||||||
use person::PersonRegistry;
|
use person::PersonRegistry;
|
||||||
@@ -641,7 +641,12 @@ impl DeviceRegistry {
|
|||||||
v_flex()
|
v_flex()
|
||||||
.gap_2()
|
.gap_2()
|
||||||
.text_sm()
|
.text_sm()
|
||||||
.child(SharedString::from(MSG))
|
.child(
|
||||||
|
div()
|
||||||
|
.text_sm()
|
||||||
|
.line_height(relative(1.25))
|
||||||
|
.child(SharedString::from(MSG)),
|
||||||
|
)
|
||||||
.child(
|
.child(
|
||||||
v_flex()
|
v_flex()
|
||||||
.gap_2()
|
.gap_2()
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use std::sync::Arc;
|
|||||||
use anyhow::{Context as AnyhowContext, Error, anyhow};
|
use anyhow::{Context as AnyhowContext, Error, anyhow};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
App, AppContext, Context, Entity, Global, IntoElement, ParentElement, SharedString, Styled,
|
App, AppContext, Context, Entity, Global, IntoElement, ParentElement, SharedString, Styled,
|
||||||
Task, Window,
|
Task, Window, div, relative,
|
||||||
};
|
};
|
||||||
use nostr_sdk::prelude::*;
|
use nostr_sdk::prelude::*;
|
||||||
use settings::{AppSettings, AuthMode};
|
use settings::{AppSettings, AuthMode};
|
||||||
@@ -284,7 +284,7 @@ impl RelayAuth {
|
|||||||
|
|
||||||
window.push_notification(
|
window.push_notification(
|
||||||
Notification::success(format!(
|
Notification::success(format!(
|
||||||
"{} has been authenticated",
|
"Relay {} has been authenticated",
|
||||||
url.domain().unwrap_or_default()
|
url.domain().unwrap_or_default()
|
||||||
)),
|
)),
|
||||||
cx,
|
cx,
|
||||||
@@ -332,8 +332,12 @@ impl RelayAuth {
|
|||||||
.content(move |_this, _window, cx| {
|
.content(move |_this, _window, cx| {
|
||||||
v_flex()
|
v_flex()
|
||||||
.gap_2()
|
.gap_2()
|
||||||
|
.child(
|
||||||
|
div()
|
||||||
.text_sm()
|
.text_sm()
|
||||||
.child(SharedString::from(AUTH_MESSAGE))
|
.line_height(relative(1.25))
|
||||||
|
.child(SharedString::from(AUTH_MESSAGE)),
|
||||||
|
)
|
||||||
.child(
|
.child(
|
||||||
v_flex()
|
v_flex()
|
||||||
.py_1()
|
.py_1()
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use gpui::{
|
|||||||
Animation, AnimationExt, AnyElement, App, AppContext, ClickEvent, Context, DismissEvent,
|
Animation, AnimationExt, AnyElement, App, AppContext, ClickEvent, Context, DismissEvent,
|
||||||
ElementId, Entity, EventEmitter, InteractiveElement as _, IntoElement, ParentElement as _,
|
ElementId, Entity, EventEmitter, InteractiveElement as _, IntoElement, ParentElement as _,
|
||||||
Render, SharedString, StatefulInteractiveElement, StyleRefinement, Styled, Subscription,
|
Render, SharedString, StatefulInteractiveElement, StyleRefinement, Styled, Subscription,
|
||||||
Window, div, px,
|
Window, div, px, relative,
|
||||||
};
|
};
|
||||||
use theme::{ActiveTheme, Anchor};
|
use theme::{ActiveTheme, Anchor};
|
||||||
|
|
||||||
@@ -332,7 +332,7 @@ impl Render for Notification {
|
|||||||
.items_start()
|
.items_start()
|
||||||
.refine_style(&self.style)
|
.refine_style(&self.style)
|
||||||
.when_some(icon, |this, icon| {
|
.when_some(icon, |this, icon| {
|
||||||
this.child(div().flex_shrink_0().pt(px(3.)).child(icon))
|
this.child(div().flex_shrink_0().child(icon))
|
||||||
})
|
})
|
||||||
.child(
|
.child(
|
||||||
v_flex()
|
v_flex()
|
||||||
@@ -342,7 +342,7 @@ impl Render for Notification {
|
|||||||
this.child(div().text_sm().font_semibold().child(title))
|
this.child(div().text_sm().font_semibold().child(title))
|
||||||
})
|
})
|
||||||
.when_some(self.message.clone(), |this, message| {
|
.when_some(self.message.clone(), |this, message| {
|
||||||
this.child(div().text_sm().child(message))
|
this.child(div().text_sm().line_height(relative(1.25)).child(message))
|
||||||
})
|
})
|
||||||
.when_some(content, |this, content| this.child(content))
|
.when_some(content, |this, content| this.child(content))
|
||||||
.when_some(action, |this, action| {
|
.when_some(action, |this, action| {
|
||||||
@@ -352,8 +352,8 @@ impl Render for Notification {
|
|||||||
.child(
|
.child(
|
||||||
div()
|
div()
|
||||||
.absolute()
|
.absolute()
|
||||||
.top_2p5()
|
.top_2()
|
||||||
.right_2p5()
|
.right_2()
|
||||||
.invisible()
|
.invisible()
|
||||||
.group_hover("", |this| this.visible())
|
.group_hover("", |this| this.visible())
|
||||||
.child(
|
.child(
|
||||||
@@ -361,7 +361,9 @@ impl Render for Notification {
|
|||||||
.icon(IconName::Close)
|
.icon(IconName::Close)
|
||||||
.ghost()
|
.ghost()
|
||||||
.xsmall()
|
.xsmall()
|
||||||
.on_click(cx.listener(|this, _, window, cx| this.dismiss(window, cx))),
|
.on_click(cx.listener(move |this, _ev, window, cx| {
|
||||||
|
this.dismiss(window, cx);
|
||||||
|
})),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.when_some(self.on_click.clone(), |this, on_click| {
|
.when_some(self.on_click.clone(), |this, on_click| {
|
||||||
|
|||||||
Reference in New Issue
Block a user