optimize
Rust / build (macos-latest, stable) (push) Canceled after 0s
Rust / build (ubuntu-latest, stable) (push) Canceled after 0s
Rust / build (windows-latest, stable) (push) Canceled after 0s
Rust / build (macos-latest, stable) (pull_request) Canceled after 0s
Rust / build (ubuntu-latest, stable) (pull_request) Canceled after 0s
Rust / build (windows-latest, stable) (pull_request) Canceled after 0s
Rust / build (macos-latest, stable) (push) Canceled after 0s
Rust / build (ubuntu-latest, stable) (push) Canceled after 0s
Rust / build (windows-latest, stable) (push) Canceled after 0s
Rust / build (macos-latest, stable) (pull_request) Canceled after 0s
Rust / build (ubuntu-latest, stable) (pull_request) Canceled after 0s
Rust / build (windows-latest, stable) (pull_request) Canceled after 0s
This commit is contained in:
@@ -1066,7 +1066,7 @@ impl Backend {
|
|||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
for url in user_grasp_list_servers(client.clone(), public_key).await? {
|
for url in user_grasp_list_servers(&client, public_key).await? {
|
||||||
client.add_relay(url).and_connect().await.ok();
|
client.add_relay(url).and_connect().await.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1525,7 +1525,7 @@ fn latest_grasp_list_servers(events: Vec<Event>) -> Vec<RelayUrl> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn user_grasp_list_servers(
|
pub async fn user_grasp_list_servers(
|
||||||
client: Client,
|
client: &Client,
|
||||||
user: PublicKey,
|
user: PublicKey,
|
||||||
) -> Result<Vec<RelayUrl>, Error> {
|
) -> Result<Vec<RelayUrl>, Error> {
|
||||||
let events: Vec<Event> = client
|
let events: Vec<Event> = client
|
||||||
|
|||||||
@@ -104,11 +104,16 @@ impl Inbox {
|
|||||||
|
|
||||||
/// Sign the state with a random key and store it locally.
|
/// Sign the state with a random key and store it locally.
|
||||||
fn persist(&mut self, cx: &mut Context<Self>) {
|
fn persist(&mut self, cx: &mut Context<Self>) {
|
||||||
let Some(me) = Backend::global(cx).read(cx).current_user() else {
|
let backend = Backend::global(cx);
|
||||||
|
let (me, client) = {
|
||||||
|
let backend = backend.read(cx);
|
||||||
|
(backend.current_user(), backend.client())
|
||||||
|
};
|
||||||
|
|
||||||
|
let Some(me) = me else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
let client = Backend::global(cx).read(cx).client();
|
|
||||||
let state = self.state.clone();
|
let state = self.state.clone();
|
||||||
|
|
||||||
let task: Task<Result<(), Error>> = cx.background_spawn(async move {
|
let task: Task<Result<(), Error>> = cx.background_spawn(async move {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use std::path::PathBuf;
|
|||||||
|
|
||||||
use anyhow::{Error, bail};
|
use anyhow::{Error, bail};
|
||||||
use bitcoin_hashes::sha1::Hash as Sha1Hash;
|
use bitcoin_hashes::sha1::Hash as Sha1Hash;
|
||||||
use gpui::{App, AppContext, AsyncApp, Context, SharedString, Subscription, Task, WeakEntity};
|
use gpui::{App, AppContext, Context, SharedString, Subscription, Task};
|
||||||
use nostr::event::IntoEventBuilder;
|
use nostr::event::IntoEventBuilder;
|
||||||
use nostr_sdk::prelude::*;
|
use nostr_sdk::prelude::*;
|
||||||
use settings::{EventFetchingStrategy, SettingsStore};
|
use settings::{EventFetchingStrategy, SettingsStore};
|
||||||
@@ -13,6 +13,7 @@ use signed_core::{
|
|||||||
pull_request_patches,
|
pull_request_patches,
|
||||||
};
|
};
|
||||||
use signed_git::Nip34Binding;
|
use signed_git::Nip34Binding;
|
||||||
|
use signed_nostr::UniversalSigner;
|
||||||
|
|
||||||
use crate::backend::{
|
use crate::backend::{
|
||||||
Backend, BackendEvent, grasp_base_url, grasp06_prs_url, pr_clone_urls, require_relay_accepted,
|
Backend, BackendEvent, grasp_base_url, grasp06_prs_url, pr_clone_urls, require_relay_accepted,
|
||||||
@@ -733,9 +734,12 @@ impl RepoStore {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let backend = Backend::global(cx);
|
let backend = Backend::global(cx);
|
||||||
let signer = backend.read(cx).signer();
|
let (signer, client, user) = {
|
||||||
|
let backend = backend.read(cx);
|
||||||
|
(backend.signer(), backend.client(), backend.current_user())
|
||||||
|
};
|
||||||
|
|
||||||
let Some(user) = backend.read(cx).current_user() else {
|
let Some(user) = user else {
|
||||||
self.last_error = Some("Sign in to open a pull request".into());
|
self.last_error = Some("Sign in to open a pull request".into());
|
||||||
cx.notify();
|
cx.notify();
|
||||||
return;
|
return;
|
||||||
@@ -774,8 +778,8 @@ impl RepoStore {
|
|||||||
// The PR references the root patch,
|
// The PR references the root patch,
|
||||||
// viewers can then find the patch without carrying it inline.
|
// viewers can then find the patch without carrying it inline.
|
||||||
let root_patch = match publish_patch_series(
|
let root_patch = match publish_patch_series(
|
||||||
&this,
|
&client,
|
||||||
cx,
|
&signer,
|
||||||
&addr,
|
&addr,
|
||||||
owner,
|
owner,
|
||||||
euc.as_deref(),
|
euc.as_deref(),
|
||||||
@@ -800,11 +804,14 @@ impl RepoStore {
|
|||||||
// Resolve the servers from the author's latest kind-10317 grasp list.
|
// Resolve the servers from the author's latest kind-10317 grasp list.
|
||||||
// The settings defaults stand in when no list is published or the query fails.
|
// The settings defaults stand in when no list is published or the query fails.
|
||||||
let author_servers = {
|
let author_servers = {
|
||||||
let query = this.update(cx, |_this, cx| {
|
let query_client = client.clone();
|
||||||
let client = Backend::global(cx).read(cx).client();
|
let published = cx
|
||||||
user_grasp_list_servers(client, user)
|
.background_spawn(
|
||||||
})?;
|
async move { user_grasp_list_servers(&query_client, user).await },
|
||||||
match cx.background_spawn(query).await {
|
)
|
||||||
|
.await;
|
||||||
|
|
||||||
|
match published {
|
||||||
Ok(published) if !published.is_empty() => published,
|
Ok(published) if !published.is_empty() => published,
|
||||||
_ => defaults,
|
_ => defaults,
|
||||||
}
|
}
|
||||||
@@ -924,8 +931,6 @@ impl RepoStore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let client = this.update(cx, |_this, cx| Backend::global(cx).read(cx).client())?;
|
|
||||||
|
|
||||||
let publish_result: Result<Event, Error> = async {
|
let publish_result: Result<Event, Error> = async {
|
||||||
let output = client.send_event(&event).broadcast().await?;
|
let output = client.send_event(&event).broadcast().await?;
|
||||||
require_relay_accepted(output, event)
|
require_relay_accepted(output, event)
|
||||||
@@ -1016,8 +1021,12 @@ impl RepoStore {
|
|||||||
self.last_warning = None;
|
self.last_warning = None;
|
||||||
|
|
||||||
let backend = Backend::global(cx);
|
let backend = Backend::global(cx);
|
||||||
|
let (user, client, signer) = {
|
||||||
|
let backend = backend.read(cx);
|
||||||
|
(backend.current_user(), backend.client(), backend.signer())
|
||||||
|
};
|
||||||
|
|
||||||
let Some(user) = backend.read(cx).current_user() else {
|
let Some(user) = user else {
|
||||||
self.last_error = Some("Sign in to update the pull request".into());
|
self.last_error = Some("Sign in to update the pull request".into());
|
||||||
cx.notify();
|
cx.notify();
|
||||||
return;
|
return;
|
||||||
@@ -1071,9 +1080,11 @@ impl RepoStore {
|
|||||||
self.not_announced(cx);
|
self.not_announced(cx);
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
let owner = addr.public_key;
|
let owner = addr.public_key;
|
||||||
let euc = self.announcement.as_ref().and_then(|a| a.euc.clone());
|
let euc = self.announcement.as_ref().and_then(|a| a.euc.clone());
|
||||||
let root = root.clone();
|
let root = root.clone();
|
||||||
|
|
||||||
let clone: Vec<Url> = self
|
let clone: Vec<Url> = self
|
||||||
.announcement
|
.announcement
|
||||||
.as_ref()
|
.as_ref()
|
||||||
@@ -1082,8 +1093,8 @@ impl RepoStore {
|
|||||||
|
|
||||||
let task: Task<Result<(), Error>> = cx.spawn(async move |this, cx| {
|
let task: Task<Result<(), Error>> = cx.spawn(async move |this, cx| {
|
||||||
if let Err(e) = publish_patch_series(
|
if let Err(e) = publish_patch_series(
|
||||||
&this,
|
&client,
|
||||||
cx,
|
&signer,
|
||||||
&addr,
|
&addr,
|
||||||
owner,
|
owner,
|
||||||
euc.as_deref(),
|
euc.as_deref(),
|
||||||
@@ -1099,7 +1110,7 @@ impl RepoStore {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let builder = this.update(cx, |_this, _cx| {
|
let builder = {
|
||||||
let builder = GitPullRequestUpdate {
|
let builder = GitPullRequestUpdate {
|
||||||
repository: addr.clone(),
|
repository: addr.clone(),
|
||||||
pull_request_event: root.id,
|
pull_request_event: root.id,
|
||||||
@@ -1116,13 +1127,7 @@ impl RepoStore {
|
|||||||
Some(euc) => builder.tag(Tag::parse(["r", euc]).expect("valid r tag")),
|
Some(euc) => builder.tag(Tag::parse(["r", euc]).expect("valid r tag")),
|
||||||
None => builder,
|
None => builder,
|
||||||
}
|
}
|
||||||
})?;
|
};
|
||||||
|
|
||||||
let (client, signer) = this.update(cx, |_this, cx| {
|
|
||||||
let backend = Backend::global(cx);
|
|
||||||
let backend = backend.read(cx);
|
|
||||||
(backend.client(), backend.signer())
|
|
||||||
})?;
|
|
||||||
|
|
||||||
let publish_result: Result<Event, Error> = async {
|
let publish_result: Result<Event, Error> = async {
|
||||||
let event = builder.finalize_async(&signer).await?;
|
let event = builder.finalize_async(&signer).await?;
|
||||||
@@ -1652,8 +1657,8 @@ fn patch_current_commit(patch: &str) -> Option<&str> {
|
|||||||
/// Returns the root event, the one a PR references.
|
/// Returns the root event, the one a PR references.
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
async fn publish_patch_series(
|
async fn publish_patch_series(
|
||||||
this: &WeakEntity<RepoStore>,
|
client: &Client,
|
||||||
cx: &mut AsyncApp,
|
signer: &UniversalSigner,
|
||||||
addr: &RepoAddr,
|
addr: &RepoAddr,
|
||||||
owner: PublicKey,
|
owner: PublicKey,
|
||||||
euc: Option<&str>,
|
euc: Option<&str>,
|
||||||
@@ -1661,12 +1666,6 @@ async fn publish_patch_series(
|
|||||||
first_marker: &str,
|
first_marker: &str,
|
||||||
reply_to: Option<EventId>,
|
reply_to: Option<EventId>,
|
||||||
) -> Result<Event, Error> {
|
) -> Result<Event, Error> {
|
||||||
let (client, signer) = this.update(cx, |_this, cx| {
|
|
||||||
let backend = Backend::global(cx);
|
|
||||||
let backend = backend.read(cx);
|
|
||||||
(backend.client(), backend.signer())
|
|
||||||
})?;
|
|
||||||
|
|
||||||
let mut root: Option<Event> = None;
|
let mut root: Option<Event> = None;
|
||||||
let mut previous = reply_to;
|
let mut previous = reply_to;
|
||||||
|
|
||||||
@@ -1679,6 +1678,7 @@ async fn publish_patch_series(
|
|||||||
};
|
};
|
||||||
|
|
||||||
let mut tags = vec![Tag::coordinate(addr.clone(), None), Tag::public_key(owner)];
|
let mut tags = vec![Tag::coordinate(addr.clone(), None), Tag::public_key(owner)];
|
||||||
|
|
||||||
if ix == 0 {
|
if ix == 0 {
|
||||||
if let Ok(tag) = Tag::parse(["t", first_marker]) {
|
if let Ok(tag) = Tag::parse(["t", first_marker]) {
|
||||||
tags.push(tag);
|
tags.push(tag);
|
||||||
@@ -1693,21 +1693,23 @@ async fn publish_patch_series(
|
|||||||
{
|
{
|
||||||
tags.push(tag);
|
tags.push(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(euc) = euc
|
if let Some(euc) = euc
|
||||||
&& let Ok(tag) = Tag::parse(["r", euc])
|
&& let Ok(tag) = Tag::parse(["r", euc])
|
||||||
{
|
{
|
||||||
tags.push(tag);
|
tags.push(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Ok(tag) = Tag::parse(["commit", commit]) {
|
if let Ok(tag) = Tag::parse(["commit", commit]) {
|
||||||
tags.push(tag);
|
tags.push(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Ok(tag) = Tag::parse(["r", commit]) {
|
if let Ok(tag) = Tag::parse(["r", commit]) {
|
||||||
tags.push(tag);
|
tags.push(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
let builder = EventBuilder::new(Kind::GitPatch, part.clone()).tags(tags);
|
let builder = EventBuilder::new(Kind::GitPatch, part.clone()).tags(tags);
|
||||||
|
let event = builder.finalize_async(signer).await?;
|
||||||
let event = builder.finalize_async(&signer).await?;
|
|
||||||
let output = client.send_event(&event).broadcast().await?;
|
let output = client.send_event(&event).broadcast().await?;
|
||||||
let event = require_relay_accepted(output, event)?;
|
let event = require_relay_accepted(output, event)?;
|
||||||
|
|
||||||
|
|||||||
@@ -187,12 +187,16 @@ impl InboxView {
|
|||||||
self.refresh.begin();
|
self.refresh.begin();
|
||||||
|
|
||||||
let backend = Backend::global(cx);
|
let backend = Backend::global(cx);
|
||||||
let Some(me) = backend.read(cx).current_user() else {
|
let (me, client) = {
|
||||||
|
let backend = backend.read(cx);
|
||||||
|
(backend.current_user(), backend.client())
|
||||||
|
};
|
||||||
|
|
||||||
|
let Some(me) = me else {
|
||||||
self.refresh.abort();
|
self.refresh.abort();
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
let client = backend.read(cx).client();
|
|
||||||
let state = self.state.clone();
|
let state = self.state.clone();
|
||||||
|
|
||||||
let work = cx.background_spawn(async move { query_inbox(&client, me, &state).await });
|
let work = cx.background_spawn(async move { query_inbox(&client, me, &state).await });
|
||||||
|
|||||||
@@ -215,15 +215,19 @@ pub fn load_user_grasp_servers(
|
|||||||
cx: &mut App,
|
cx: &mut App,
|
||||||
) {
|
) {
|
||||||
let backend = Backend::global(cx);
|
let backend = Backend::global(cx);
|
||||||
let Some(user) = backend.read(cx).current_user() else {
|
let (user, client) = {
|
||||||
|
let backend = backend.read(cx);
|
||||||
|
(backend.current_user(), backend.client())
|
||||||
|
};
|
||||||
|
|
||||||
|
let Some(user) = user else {
|
||||||
state.update(cx, |state, _| state.loading_servers = false);
|
state.update(cx, |state, _| state.loading_servers = false);
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
let client = backend.read(cx).client();
|
|
||||||
let handle = window.window_handle();
|
let handle = window.window_handle();
|
||||||
|
|
||||||
cx.spawn(async move |cx| {
|
cx.spawn(async move |cx| {
|
||||||
let result = signed_state::user_grasp_list_servers(client, user).await;
|
let result = signed_state::user_grasp_list_servers(&client, user).await;
|
||||||
|
|
||||||
let _ = cx.update_window(handle, |_, _window, cx| {
|
let _ = cx.update_window(handle, |_, _window, cx| {
|
||||||
state.update(cx, |state, _| {
|
state.update(cx, |state, _| {
|
||||||
|
|||||||
Reference in New Issue
Block a user