chore: update gpui and nostr sdk

This commit is contained in:
2025-06-25 20:00:05 +07:00
parent edee9305cc
commit 3c2eaabab2
14 changed files with 209 additions and 295 deletions

View File

@@ -24,6 +24,7 @@ reqwest_client.workspace = true
nostr-connect.workspace = true
nostr-sdk.workspace = true
nostr.workspace = true
anyhow.workspace = true
serde.workspace = true

View File

@@ -7,8 +7,8 @@ use global::constants::{DEFAULT_MODAL_WIDTH, DEFAULT_SIDEBAR_WIDTH};
use global::shared_state;
use gpui::prelude::FluentBuilder;
use gpui::{
div, impl_internal_actions, px, relative, App, AppContext, Axis, Context, Entity, IntoElement,
ParentElement, Render, Styled, Subscription, Task, Window,
div, px, relative, Action, App, AppContext, Axis, Context, Entity, IntoElement, ParentElement,
Render, Styled, Subscription, Task, Window,
};
use identity::Identity;
use nostr_connect::prelude::*;
@@ -25,8 +25,6 @@ use ui::{ContextModal, IconName, Root, Sizable, StyledExt, TitleBar};
use crate::views::chat::{self, Chat};
use crate::views::{login, new_account, onboarding, preferences, sidebar, startup, welcome};
impl_internal_actions!(dock, [ToggleModal]);
pub fn init(window: &mut Window, cx: &mut App) -> Entity<ChatSpace> {
ChatSpace::new(window, cx)
}
@@ -56,7 +54,8 @@ pub enum ModalKind {
SetupRelay,
}
#[derive(Clone, PartialEq, Eq, Deserialize)]
#[derive(Action, Clone, PartialEq, Eq, Deserialize)]
#[action(namespace = modal, no_json)]
pub struct ToggleModal {
pub modal: ModalKind,
}

View File

@@ -10,11 +10,11 @@ use common::profile::RenderProfile;
use global::shared_state;
use gpui::prelude::FluentBuilder;
use gpui::{
div, img, impl_internal_actions, list, px, red, relative, rems, svg, white, AnyElement, App,
AppContext, ClipboardItem, Context, Div, Element, Empty, Entity, EventEmitter, Flatten,
FocusHandle, Focusable, InteractiveElement, IntoElement, ListAlignment, ListState, ObjectFit,
ParentElement, PathPromptOptions, Render, RetainAllImageCache, SharedString,
StatefulInteractiveElement, Styled, StyledImage, Subscription, Window,
div, img, list, px, red, relative, rems, svg, white, Action, AnyElement, App, AppContext,
ClipboardItem, Context, Div, Element, Empty, Entity, EventEmitter, Flatten, FocusHandle,
Focusable, InteractiveElement, IntoElement, ListAlignment, ListState, ObjectFit, ParentElement,
PathPromptOptions, Render, RetainAllImageCache, SharedString, StatefulInteractiveElement,
Styled, StyledImage, Subscription, Window,
};
use identity::Identity;
use itertools::Itertools;
@@ -38,11 +38,10 @@ use ui::{
use crate::views::subject;
#[derive(Clone, PartialEq, Eq, Deserialize)]
#[derive(Action, Clone, PartialEq, Eq, Deserialize)]
#[action(namespace = chat, no_json)]
pub struct ChangeSubject(pub String);
impl_internal_actions!(chat, [ChangeSubject]);
pub fn init(room: Entity<Room>, window: &mut Window, cx: &mut App) -> Arc<Entity<Chat>> {
Arc::new(Chat::new(room, window, cx))
}

View File

@@ -4,17 +4,17 @@ use std::time::Duration;
use anyhow::{anyhow, Error};
use chats::room::{Room, RoomKind};
use chats::ChatRegistry;
use common::nip05_profile;
use common::profile::RenderProfile;
use global::shared_state;
use gpui::prelude::FluentBuilder;
use gpui::{
div, img, impl_internal_actions, px, red, relative, uniform_list, App, AppContext, Context,
Entity, InteractiveElement, IntoElement, ParentElement, Render, SharedString,
div, img, px, red, relative, uniform_list, App, AppContext, Context, Entity,
InteractiveElement, IntoElement, ParentElement, Render, SharedString,
StatefulInteractiveElement, Styled, Subscription, Task, TextAlign, Window,
};
use itertools::Itertools;
use nostr_sdk::prelude::*;
use serde::Deserialize;
use settings::AppSettings;
use smallvec::{smallvec, SmallVec};
use smol::Timer;
@@ -28,11 +28,6 @@ pub fn init(window: &mut Window, cx: &mut App) -> Entity<Compose> {
cx.new(|cx| Compose::new(window, cx))
}
#[derive(Clone, PartialEq, Eq, Deserialize)]
struct SelectContact(PublicKey);
impl_internal_actions!(contacts, [SelectContact]);
#[derive(Debug, Clone)]
struct Contact {
profile: Profile,
@@ -245,15 +240,14 @@ impl Compose {
let task: Task<Result<Contact, anyhow::Error>> = if content.contains("@") {
cx.background_spawn(async move {
let (tx, rx) = oneshot::channel::<Nip05Profile>();
let (tx, rx) = oneshot::channel::<Option<Nip05Profile>>();
nostr_sdk::async_utility::task::spawn(async move {
if let Ok(profile) = nip05::profile(&content, None).await {
tx.send(profile).ok();
}
let profile = nip05_profile(&content).await.ok();
tx.send(profile).ok();
});
if let Ok(profile) = rx.await {
if let Ok(Some(profile)) = rx.await {
let public_key = profile.public_key;
let metadata = shared_state()
.client()

View File

@@ -7,6 +7,7 @@ use chats::room::{Room, RoomKind};
use chats::{ChatRegistry, RoomEmitter};
use common::debounced_delay::DebouncedDelay;
use common::profile::RenderProfile;
use common::verify_nip05;
use element::DisplayRoom;
use global::constants::{DEFAULT_MODAL_WIDTH, SEARCH_RELAYS};
use global::shared_state;
@@ -184,13 +185,8 @@ impl Sidebar {
continue;
};
let Ok(verified) = nip05::verify(&event.pubkey, target, None).await else {
// Skip if NIP-05 verification fails
continue;
};
if !verified {
// Skip if NIP-05 is not valid
if !verify_nip05(event.pubkey, target).await.unwrap_or(false) {
// Skip if NIP-05 is not valid or failed to verify
continue;
};