refactor signer

This commit is contained in:
2026-07-23 11:14:56 +07:00
parent ab665cd661
commit bf6ae65b05
22 changed files with 291 additions and 567 deletions

View File

@@ -82,7 +82,7 @@ impl ContactListPanel {
let nostr = NostrRegistry::global(cx);
let client = nostr.read(cx).client();
let Some(public_key) = nostr.read(cx).signer_pubkey(cx) else {
let Some(public_key) = nostr.read(cx).current_user() else {
return;
};
@@ -157,10 +157,7 @@ impl ContactListPanel {
let nostr = NostrRegistry::global(cx);
let client = nostr.read(cx).client();
let Some(signer) = nostr.read(cx).signer(cx) else {
return;
};
let signer = nostr.read(cx).signer();
// Get contacts
let contacts: Vec<Contact> = self

View File

@@ -31,7 +31,7 @@ impl GreeterPanel {
fn add_profile_panel(&mut self, window: &mut Window, cx: &mut Context<Self>) {
let nostr = NostrRegistry::global(cx);
if let Some(public_key) = nostr.read(cx).signer_pubkey(cx) {
if let Some(public_key) = nostr.read(cx).current_user() {
cx.spawn_in(window, async move |_this, cx| {
cx.update(|window, cx| {
Workspace::add_panel(

View File

@@ -83,7 +83,7 @@ impl MessagingRelayPanel {
let nostr = NostrRegistry::global(cx);
let client = nostr.read(cx).client();
let Some(public_key) = nostr.read(cx).signer_pubkey(cx) else {
let Some(public_key) = nostr.read(cx).current_user() else {
return;
};
@@ -171,10 +171,7 @@ impl MessagingRelayPanel {
let nostr = NostrRegistry::global(cx);
let client = nostr.read(cx).client();
let Some(signer) = nostr.read(cx).signer(cx) else {
return;
};
let signer = nostr.read(cx).signer();
// Construct event tags
let tags: Vec<Tag> = self

View File

@@ -1,7 +1,7 @@
use std::str::FromStr;
use std::time::Duration;
use anyhow::{Context as AnyhowContext, Error, anyhow};
use anyhow::{Context as AnyhowContext, Error};
use gpui::{
AnyElement, App, AppContext, ClipboardItem, Context, Entity, EventEmitter, FocusHandle,
Focusable, IntoElement, ParentElement, PathPromptOptions, Render, SharedString, Styled, Task,
@@ -207,12 +207,9 @@ impl ProfilePanel {
fn publish(&self, metadata: &Metadata, cx: &App) -> Task<Result<(), Error>> {
let nostr = NostrRegistry::global(cx);
let client = nostr.read(cx).client();
let signer = nostr.read(cx).signer();
let metadata = metadata.clone();
let Some(signer) = nostr.read(cx).signer(cx) else {
return Task::ready(Err(anyhow!("Signer is required")));
};
cx.background_spawn(async move {
// Build and sign the metadata event
let event = metadata.finalize_async(&signer).await?;

View File

@@ -100,7 +100,7 @@ impl RelayListPanel {
let nostr = NostrRegistry::global(cx);
let client = nostr.read(cx).client();
let Some(public_key) = nostr.read(cx).signer_pubkey(cx) else {
let Some(public_key) = nostr.read(cx).current_user() else {
return;
};
@@ -207,10 +207,7 @@ impl RelayListPanel {
let nostr = NostrRegistry::global(cx);
let client = nostr.read(cx).client();
let Some(signer) = nostr.read(cx).signer(cx) else {
return;
};
let signer = nostr.read(cx).signer();
// Get all relays
let relays = self.relays.clone();