chore: Improve Request Screening (#101)

* open chat while screening

* close panel on ignore

* bypass screening

* .

* improve settings

* refine modal

* .

* .

* .

* .

* .
This commit is contained in:
reya
2025-07-27 07:22:31 +07:00
committed by GitHub
parent 91cca37d69
commit 3cf9dde882
40 changed files with 1038 additions and 2035 deletions
+42 -38
View File
@@ -4,7 +4,7 @@ use std::time::Duration;
use anyhow::{anyhow, Error};
use common::debounced_delay::DebouncedDelay;
use common::display::DisplayProfile;
use common::display::{DisplayProfile, TextUtils};
use global::constants::{BOOTSTRAP_RELAYS, DEFAULT_MODAL_WIDTH, SEARCH_RELAYS};
use global::nostr_client;
use gpui::prelude::FluentBuilder;
@@ -32,7 +32,7 @@ use ui::indicator::Indicator;
use ui::input::{InputEvent, InputState, TextInput};
use ui::popup_menu::PopupMenu;
use ui::skeleton::Skeleton;
use ui::{ContextModal, IconName, Selectable, Sizable, StyledExt};
use ui::{v_flex, ContextModal, IconName, Selectable, Sizable, StyledExt};
use crate::views::compose;
@@ -146,6 +146,8 @@ impl Sidebar {
.subscribe_to(BOOTSTRAP_RELAYS, filter, Some(opts))
.await?;
log::info!("Subscribe to get metadata for: {public_key}");
Ok(())
}
@@ -334,7 +336,7 @@ impl Sidebar {
}
fn search_by_pubkey(&mut self, query: &str, window: &mut Window, cx: &mut Context<Self>) {
let Ok(public_key) = common::parse_pubkey_from_str(query) else {
let Ok(public_key) = query.to_public_key() else {
window.push_notification(t!("common.pubkey_invalid"), cx);
self.set_finding(false, window, cx);
return;
@@ -568,36 +570,34 @@ impl Sidebar {
let desc = SharedString::new(t!("sidebar.loading_modal_description"));
window.open_modal(cx, move |this, _window, cx| {
this.child(
div()
.pt_8()
.px_4()
.pb_4()
.flex()
.flex_col()
.gap_2()
.child(div().font_semibold().child(title.clone()))
.child(
div()
.flex()
.flex_col()
.gap_2()
.text_sm()
.child(text_1.clone())
.child(text_2.clone()),
)
.child(
div()
.text_xs()
.text_color(cx.theme().text_muted)
.child(desc.clone()),
),
)
this.show_close(true)
.keyboard(true)
.title(title.clone())
.child(
v_flex()
.pb_4()
.gap_2()
.child(
div()
.flex()
.flex_col()
.gap_2()
.text_sm()
.child(text_1.clone())
.child(text_2.clone()),
)
.child(
div()
.text_xs()
.text_color(cx.theme().text_muted)
.child(desc.clone()),
),
)
});
}
fn account(&self, profile: &Profile, cx: &Context<Self>) -> impl IntoElement {
let proxy = AppSettings::get_global(cx).settings.proxy_user_avatars;
let proxy = AppSettings::get_proxy_user_avatars(cx);
div()
.px_3()
@@ -666,26 +666,30 @@ impl Sidebar {
range: Range<usize>,
cx: &Context<Self>,
) -> Vec<impl IntoElement> {
let proxy = AppSettings::get_global(cx).settings.proxy_user_avatars;
let proxy = AppSettings::get_proxy_user_avatars(cx);
let mut items = Vec::with_capacity(range.end - range.start);
for ix in range {
if let Some(room) = rooms.get(ix) {
let this = room.read(cx);
let room_id = this.id;
let handler = cx.listener({
let id = this.id;
move |this, _, window, cx| {
this.open_room(id, window, cx);
this.open_room(room_id, window, cx);
}
});
items.push(
RoomListItem::new(ix, this.members[0])
.avatar(this.display_image(proxy, cx))
.name(this.display_name(cx))
.created_at(this.ago())
.kind(this.kind)
.on_click(handler),
RoomListItem::new(
ix,
room_id,
this.members[0],
this.display_name(cx),
this.display_image(proxy, cx),
this.ago(),
this.kind,
)
.on_click(handler),
)
}
}