notedeck

One damus client to rule them all
git clone git://jb55.com/notedeck
Log | Files | Refs | README | LICENSE

commit 317320cce2aa2a76daa925f844dbae726ba69ad2
parent ae498ff9e3633728b4cc7547cfba63cb193e1579
Author: kernelkind <kernelkind@gmail.com>
Date:   Thu, 18 Dec 2025 18:00:24 -0500

feat(msgs-ui): add `CreateConvoUi`

Signed-off-by: kernelkind <kernelkind@gmail.com>

Diffstat:
Acrates/notedeck_messages/src/ui/create_convo.rs | 67+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mcrates/notedeck_messages/src/ui/mod.rs | 1+
2 files changed, 68 insertions(+), 0 deletions(-)

diff --git a/crates/notedeck_messages/src/ui/create_convo.rs b/crates/notedeck_messages/src/ui/create_convo.rs @@ -0,0 +1,67 @@ +use egui::{Label, RichText}; +use enostr::Pubkey; +use nostrdb::{Ndb, Transaction}; +use notedeck::{tr, ContactState, Images, Localization, MediaJobSender, NotedeckTextStyle}; +use notedeck_ui::{contacts_list::ContactsCollection, ContactsListView}; + +pub struct CreateConvoUi<'a> { + ndb: &'a Ndb, + jobs: &'a MediaJobSender, + img_cache: &'a mut Images, + contacts: &'a ContactState, + i18n: &'a mut Localization, +} + +pub struct CreateConvoResponse { + pub recipient: Pubkey, +} + +impl<'a> CreateConvoUi<'a> { + pub fn new( + ndb: &'a Ndb, + jobs: &'a MediaJobSender, + img_cache: &'a mut Images, + contacts: &'a ContactState, + i18n: &'a mut Localization, + ) -> Self { + Self { + ndb, + jobs, + img_cache, + contacts, + i18n, + } + } + + pub fn ui(&mut self, ui: &mut egui::Ui) -> Option<CreateConvoResponse> { + let ContactState::Received { contacts, .. } = self.contacts else { + // TODO render something about not having contacts + return None; + }; + + let txn = Transaction::new(self.ndb).expect("txn"); + + ui.add(Label::new( + RichText::new(tr!( + self.i18n, + "Contacts", + "Heading shown when choosing a contact to start a new chat" + )) + .text_style(NotedeckTextStyle::Heading.text_style()), + )); + let resp = ContactsListView::new( + ContactsCollection::Set(contacts), + self.jobs, + self.ndb, + self.img_cache, + &txn, + ) + .ui(ui); + + resp.output.map(|a| match a { + notedeck_ui::ContactsListAction::Select(pubkey) => { + CreateConvoResponse { recipient: pubkey } + } + }) + } +} diff --git a/crates/notedeck_messages/src/ui/mod.rs b/crates/notedeck_messages/src/ui/mod.rs @@ -14,6 +14,7 @@ use crate::cache::{Conversation, ConversationCache, ConversationMetadata}; pub mod convo; pub mod convo_list; +pub mod create_convo; #[derive(Clone, Debug)] pub struct ConversationSummary<'a> {