split notedeck into crates
This splits notedeck into crates, separating the browser chrome and individual apps: * notedeck: binary file, browser chrome * notedeck_columns: our columns app * enostr: same as before We still need to do more work to cleanly separate the chrome apis from the app apis. Soon I will create notedeck-notebook to see what makes sense to be shared between the apps. Some obvious ones that come to mind: 1. ImageCache We will likely want to move this to the notedeck crate, as most apps will want some kind of image cache. In web browsers, web pages do not need to worry about this, so we will likely have to do something similar 2. Ndb Since NdbRef is threadsafe and Ndb is an Arc<NdbRef>, it can be safely copied to each app. This will simplify things. In the future we might want to create an abstraction over this? Maybe each app shouldn't have access to the same database... we assume the data in DBs are all public anyways, but if we have unwrapped giftwraps that could be a problem. 3. RelayPool / Subscription Manager The browser should probably maintain these. Then apps can use ken's high level subscription manager api and not have to worry about connection pool details 4. Accounts Accounts and key management should be handled by the chrome. Apps should only have a simple signer interface. That's all for now, just something to think about! Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
87
crates/notedeck_columns/src/ui/profile/mod.rs
Normal file
87
crates/notedeck_columns/src/ui/profile/mod.rs
Normal file
@@ -0,0 +1,87 @@
|
||||
pub mod picture;
|
||||
pub mod preview;
|
||||
|
||||
use crate::ui::note::NoteOptions;
|
||||
use egui::{ScrollArea, Widget};
|
||||
use enostr::Pubkey;
|
||||
use nostrdb::{Ndb, Transaction};
|
||||
pub use picture::ProfilePic;
|
||||
pub use preview::ProfilePreview;
|
||||
|
||||
use crate::{
|
||||
actionbar::NoteAction, imgcache::ImageCache, muted::MuteFun, notecache::NoteCache,
|
||||
notes_holder::NotesHolderStorage, profile::Profile,
|
||||
};
|
||||
|
||||
use super::timeline::{tabs_ui, TimelineTabView};
|
||||
|
||||
pub struct ProfileView<'a> {
|
||||
pubkey: &'a Pubkey,
|
||||
col_id: usize,
|
||||
profiles: &'a mut NotesHolderStorage<Profile>,
|
||||
note_options: NoteOptions,
|
||||
ndb: &'a Ndb,
|
||||
note_cache: &'a mut NoteCache,
|
||||
img_cache: &'a mut ImageCache,
|
||||
}
|
||||
|
||||
impl<'a> ProfileView<'a> {
|
||||
pub fn new(
|
||||
pubkey: &'a Pubkey,
|
||||
col_id: usize,
|
||||
profiles: &'a mut NotesHolderStorage<Profile>,
|
||||
ndb: &'a Ndb,
|
||||
note_cache: &'a mut NoteCache,
|
||||
img_cache: &'a mut ImageCache,
|
||||
note_options: NoteOptions,
|
||||
) -> Self {
|
||||
ProfileView {
|
||||
pubkey,
|
||||
col_id,
|
||||
profiles,
|
||||
ndb,
|
||||
note_cache,
|
||||
img_cache,
|
||||
note_options,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn ui(&mut self, ui: &mut egui::Ui, is_muted: &MuteFun) -> Option<NoteAction> {
|
||||
let scroll_id = egui::Id::new(("profile_scroll", self.col_id, self.pubkey));
|
||||
|
||||
ScrollArea::vertical()
|
||||
.id_salt(scroll_id)
|
||||
.show(ui, |ui| {
|
||||
let txn = Transaction::new(self.ndb).expect("txn");
|
||||
if let Ok(profile) = self.ndb.get_profile_by_pubkey(&txn, self.pubkey.bytes()) {
|
||||
ProfilePreview::new(&profile, self.img_cache).ui(ui);
|
||||
}
|
||||
let profile = self
|
||||
.profiles
|
||||
.notes_holder_mutated(
|
||||
self.ndb,
|
||||
self.note_cache,
|
||||
&txn,
|
||||
self.pubkey.bytes(),
|
||||
is_muted,
|
||||
)
|
||||
.get_ptr();
|
||||
|
||||
profile.timeline.selected_view = tabs_ui(ui);
|
||||
|
||||
let reversed = false;
|
||||
|
||||
TimelineTabView::new(
|
||||
profile.timeline.current_view(),
|
||||
reversed,
|
||||
self.note_options,
|
||||
&txn,
|
||||
self.ndb,
|
||||
self.note_cache,
|
||||
self.img_cache,
|
||||
)
|
||||
.show(ui)
|
||||
})
|
||||
.inner
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user