chore: update nostr-sdk

This commit is contained in:
2025-02-04 07:28:54 +07:00
parent a3389ec893
commit 3647b62308
3 changed files with 45 additions and 44 deletions

View File

@@ -17,7 +17,7 @@ use gpui::{WindowBackgroundAppearance, WindowDecorations};
use log::{error, info};
use nostr_sdk::prelude::*;
use state::{get_client, initialize_client};
use std::{collections::HashSet, ops::Deref, str::FromStr, sync::Arc, time::Duration};
use std::{borrow::Cow, collections::HashSet, ops::Deref, str::FromStr, sync::Arc, time::Duration};
use tokio::sync::mpsc;
use ui::Root;
use views::{app::AppView, onboarding::Onboarding, startup::Startup};
@@ -60,7 +60,7 @@ fn main() {
});
spawn(async move {
let (batch_tx, mut batch_rx) = mpsc::channel::<Box<Event>>(20);
let (batch_tx, mut batch_rx) = mpsc::channel::<Cow<Event>>(20);
async fn sync_metadata(client: &Client, buffer: &HashSet<PublicKey>) {
let filter = Filter::new()
@@ -73,7 +73,7 @@ fn main() {
}
}
async fn process_batch(client: &Client, events: &[Box<Event>]) {
async fn process_batch(client: &Client, events: &[Cow<'_, Event>]) {
let sig = Signature::from_str(FAKE_SIG).unwrap();
let mut buffer: HashSet<PublicKey> = HashSet::with_capacity(100);
@@ -157,7 +157,7 @@ fn main() {
subscription_id,
} => match event.kind {
Kind::GiftWrap => {
if subscription_id == new_id {
if new_id == *subscription_id {
if let Ok(UnwrappedGift { mut rumor, .. }) =
client.unwrap_gift_wrap(&event).await
{
@@ -201,7 +201,7 @@ fn main() {
_ => {}
},
RelayMessage::EndOfStoredEvents(subscription_id) => {
if subscription_id == all_id {
if all_id == *subscription_id {
if let Err(e) = signal_tx.send(Signal::Eose).await {
error!("Failed to send eose: {}", e)
};

View File

@@ -1,6 +1,6 @@
use gpui::{
actions, div, point, prelude::FluentBuilder as _, px, AnyElement, App, AppContext, Bounds,
ClipboardItem, Context, Entity, EntityInputHandler, EventEmitter, FocusHandle, Focusable, Half,
ClipboardItem, Context, Entity, EntityInputHandler, EventEmitter, FocusHandle, Focusable,
InteractiveElement as _, IntoElement, KeyBinding, KeyDownEvent, MouseButton, MouseDownEvent,
MouseMoveEvent, MouseUpEvent, ParentElement as _, Pixels, Point, Rems, Render, ScrollHandle,
ScrollWheelEvent, SharedString, Styled as _, UTF16Selection, Window, WrappedLine,
@@ -1099,16 +1099,17 @@ impl TextInput {
for line in lines.iter() {
let line_origin = self.line_origin_with_y_offset(&mut y_offset, line, line_height);
let mut pos = inner_position - line_origin;
// Ignore the y position in single line mode, only check x position.
let pos = inner_position - line_origin;
let closest_index = line.unwrapped_layout.closest_index_for_x(pos.x);
// Return offset by use closest_index_for_x if is single line mode.
if self.is_single_line() {
pos.y = line_height.half();
return closest_index;
}
let index_result = line.index_for_position(pos, line_height);
let index_result = line.closest_index_for_position(pos, line_height);
if let Ok(v) = index_result {
// Add 1 for place cursor after the character.
index += v + 1;
index += v;
break;
} else if line
.index_for_position(point(px(0.), pos.y), line_height)