chore: rewrite the backend (not tested) (#203)

* wip: refactor

* refactor

* clean up

* .

* rename

* add relay auth

* .

* .

* optimize

* .

* clean up

* add encryption crate

* .

* .

* .

* .

* .

* add encryption crate

* .

* refactor nip4e

* .

* fix endless loop

* fix metadata fetching
This commit is contained in:
reya
2025-11-11 09:09:33 +07:00
committed by GitHub
parent a1a0a7ecd4
commit 512834b640
68 changed files with 3503 additions and 3194 deletions

View File

@@ -5,7 +5,7 @@ edition.workspace = true
publish.workspace = true
[dependencies]
states = { path = "../states" }
state = { path = "../state" }
nostr-sdk.workspace = true
gpui.workspace = true

View File

@@ -3,7 +3,9 @@ use gpui::{App, AppContext, Context, Entity, Global, Subscription, Task};
use nostr_sdk::prelude::*;
use serde::{Deserialize, Serialize};
use smallvec::{smallvec, SmallVec};
use states::{app_state, SETTINGS_IDENTIFIER};
use state::NostrRegistry;
const SETTINGS_IDENTIFIER: &str = "coop:settings";
pub fn init(cx: &mut App) {
let state = cx.new(AppSettings::new);
@@ -122,8 +124,10 @@ impl AppSettings {
}
pub fn load_settings(&self, cx: &mut Context<Self>) {
let nostr = NostrRegistry::global(cx);
let client = nostr.read(cx).client();
let task: Task<Result<Settings, anyhow::Error>> = cx.background_spawn(async move {
let client = app_state().client();
let signer = client.signer().await?;
let public_key = signer.get_public_key().await?;
@@ -153,9 +157,11 @@ impl AppSettings {
}
pub fn set_settings(&self, cx: &mut Context<Self>) {
let nostr = NostrRegistry::global(cx);
let client = nostr.read(cx).client();
if let Ok(content) = serde_json::to_string(&self.setting_values) {
let task: Task<Result<(), anyhow::Error>> = cx.background_spawn(async move {
let client = app_state().client();
let signer = client.signer().await?;
let public_key = signer.get_public_key().await?;