chore: bump gpui-pre to 0.3.8 and clean up unused code

This commit is contained in:
2026-10-06 21:04:20 +07:00
parent 3ada21b728
commit 33785f183d
62 changed files with 162 additions and 3516 deletions
+6 -38
View File
@@ -101,7 +101,6 @@ pub struct ChatRegistry {
/// Signal consumer task (cancelled on signer change)
signal_consumer: Option<Task<Result<(), Error>>>,
/// Fuzzy matcher for room search (cached; intentionally excluded from Debug)
#[allow(dead_code)]
matcher: CachedMatcher,
/// Subscriptions
_subscriptions: SmallVec<[Subscription; 2]>,
@@ -549,26 +548,6 @@ impl ChatRegistry {
.count()
}
/// Count the number of messages seen by a given relay.
pub fn count_messages(&self, relay_url: &RelayUrl) -> usize {
self.seen
.read()
.unwrap()
.values()
.filter(|s| s.contains(relay_url))
.count()
}
/// Count the number of trash messages.
pub fn count_trash_messages(&self, cx: &App) -> usize {
self.trash.read(cx).len()
}
/// Get the trash messages entity.
pub fn trash(&self) -> Entity<BTreeSet<FailedMessage>> {
self.trash.clone()
}
/// Get the relays that have seen a given rumor id.
pub fn rumor_seen_on(&self, id: &EventId) -> Option<HashSet<RelayUrl>> {
self.event_map
@@ -579,7 +558,7 @@ impl ChatRegistry {
}
/// Get the relays that have seen a given gift wrap id.
pub fn seen_on(&self, id: &EventId) -> HashSet<RelayUrl> {
pub(crate) fn seen_on(&self, id: &EventId) -> HashSet<RelayUrl> {
self.seen
.read()
.unwrap()
@@ -589,7 +568,7 @@ impl ChatRegistry {
}
/// Add a new room to the start of list.
pub fn add_room<I>(&mut self, room: I, cx: &mut Context<Self>)
pub(crate) fn add_room<I>(&mut self, room: I, cx: &mut Context<Self>)
where
I: Into<Room>,
{
@@ -623,7 +602,7 @@ impl ChatRegistry {
}
/// Sort rooms by their created at. Only notifies if order changed.
pub fn sort(&mut self, cx: &mut Context<Self>) {
pub(crate) fn sort(&mut self, cx: &mut Context<Self>) {
let before: Vec<_> = self.rooms.iter().map(|ev| ev.read(cx).id).collect();
self.rooms.sort_by_key(|ev| Reverse(ev.read(cx).created_at));
let after: Vec<_> = self.rooms.iter().map(|ev| ev.read(cx).id).collect();
@@ -659,7 +638,7 @@ impl ChatRegistry {
}
/// Reset the registry.
pub fn reset(&mut self, cx: &mut Context<Self>) {
pub(crate) fn reset(&mut self, cx: &mut Context<Self>) {
self.rooms.clear();
self.room_index.clear();
self.search.write().unwrap().clear();
@@ -701,7 +680,7 @@ impl ChatRegistry {
}
/// Load all rooms from the database.
pub fn get_rooms(&mut self, cx: &mut Context<Self>) {
pub(crate) fn get_rooms(&mut self, cx: &mut Context<Self>) {
let task = self.query_chat_rooms(cx);
self.tasks.push(cx.spawn(async move |this, cx| {
@@ -796,7 +775,7 @@ impl ChatRegistry {
///
/// - If the room doesn't exist, it will be created.
/// - Updates room ordering based on the most recent messages.
pub fn new_message(&mut self, message: NewMessage, cx: &mut Context<Self>) {
pub(crate) fn new_message(&mut self, message: NewMessage, cx: &mut Context<Self>) {
self.search.write().unwrap().insert(&message.rumor);
let nostr = NostrRegistry::global(cx);
@@ -821,17 +800,6 @@ impl ChatRegistry {
}
}
}
/// Trigger a refresh of the opened chat rooms by their IDs
pub fn refresh_rooms(&mut self, ids: &[u64], cx: &mut Context<Self>) {
for room in self.rooms.iter() {
if ids.contains(&room.read(cx).id) {
room.update(cx, |this, cx| {
this.emit_refresh(cx);
});
}
}
}
}
/// Unwraps a gift-wrapped event and processes its contents.
+6 -11
View File
@@ -6,7 +6,7 @@ use gpui::{SharedString, SharedUri};
use nostr_sdk::prelude::*;
use state::FileAttachment;
pub const KIND_FILE_MESSAGE: Kind = Kind::Custom(15);
pub(crate) const KIND_FILE_MESSAGE: Kind = Kind::Custom(15);
/// Rendered message.
#[derive(Debug, Clone)]
@@ -152,31 +152,26 @@ impl Message {
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub struct NewMessage {
pub room: u64,
pub gift_wrap: EventId,
pub rumor: UnsignedEvent,
}
impl NewMessage {
pub fn new(gift_wrap: EventId, rumor: UnsignedEvent) -> Self {
pub fn new(_gift_wrap: EventId, rumor: UnsignedEvent) -> Self {
let room = rumor.uniq_id();
Self {
room,
gift_wrap,
rumor,
}
Self { room, rumor }
}
}
/// Trash message.
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub struct FailedMessage {
pub(crate) struct FailedMessage {
pub raw_event: SharedString,
pub reason: SharedString,
}
impl FailedMessage {
pub fn new<T>(event: &Event, reason: T) -> Self
pub(crate) fn new<T>(event: &Event, reason: T) -> Self
where
T: Into<SharedString>,
{
@@ -194,7 +189,7 @@ pub struct Mention {
}
impl Mention {
pub fn new(public_key: PublicKey, range: Range<usize>) -> Self {
pub(crate) fn new(public_key: PublicKey, range: Range<usize>) -> Self {
Self { public_key, range }
}
}
+7 -9
View File
@@ -78,7 +78,7 @@ pub struct Room {
pub created_at: Timestamp,
/// Subject of the room
pub subject: Option<SharedString>,
pub(crate) subject: Option<SharedString>,
/// All members of the room
pub(super) members: Vec<PublicKey>,
@@ -186,13 +186,16 @@ impl Room {
}
/// Sets this room is ongoing conversation
pub fn set_ongoing(&mut self, cx: &mut Context<Self>) {
pub(crate) fn set_ongoing(&mut self, cx: &mut Context<Self>) {
self.kind = RoomKind::Ongoing;
cx.notify();
}
/// Updates the creation timestamp of the room
pub fn set_created_at(&mut self, created_at: impl Into<Timestamp>, cx: &mut Context<Self>) {
pub(crate) fn set_created_at<T>(&mut self, created_at: T, cx: &mut Context<Self>)
where
T: Into<Timestamp>,
{
self.created_at = created_at.into();
cx.notify();
}
@@ -297,7 +300,7 @@ impl Room {
}
/// Push a new message to the current room
pub fn push_message(&mut self, message: NewMessage, cx: &mut Context<Self>) {
pub(crate) fn push_message(&mut self, message: NewMessage, cx: &mut Context<Self>) {
let created_at = message.rumor.created_at;
let new_message = created_at > self.created_at;
@@ -309,11 +312,6 @@ impl Room {
}
}
/// Emits a signal to reload the current room's messages.
pub fn emit_refresh(&mut self, cx: &mut Context<Self>) {
cx.emit(RoomEvent::Reload);
}
/// Get gossip relays for each member
pub fn connect(&self, cx: &App) -> Task<Result<(), Error>> {
let nostr = NostrRegistry::global(cx);