integrate profile view caching
Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
@@ -8,16 +8,16 @@ pub use picture::ProfilePic;
|
||||
pub use preview::ProfilePreview;
|
||||
|
||||
use crate::{
|
||||
actionbar::TimelineResponse, column::Columns, imgcache::ImageCache, notecache::NoteCache,
|
||||
timeline::TimelineId,
|
||||
actionbar::TimelineResponse, imgcache::ImageCache, notecache::NoteCache,
|
||||
notes_holder::NotesHolderStorage, profile::Profile,
|
||||
};
|
||||
|
||||
use super::TimelineView;
|
||||
use super::timeline::{tabs_ui, TimelineTabView};
|
||||
|
||||
pub struct ProfileView<'a> {
|
||||
pubkey: Pubkey,
|
||||
timeline_id: TimelineId,
|
||||
columns: &'a mut Columns,
|
||||
col_id: usize,
|
||||
profiles: &'a mut NotesHolderStorage<Profile>,
|
||||
ndb: &'a Ndb,
|
||||
note_cache: &'a mut NoteCache,
|
||||
img_cache: &'a mut ImageCache,
|
||||
@@ -26,16 +26,16 @@ pub struct ProfileView<'a> {
|
||||
impl<'a> ProfileView<'a> {
|
||||
pub fn new(
|
||||
pubkey: Pubkey,
|
||||
timeline_id: TimelineId,
|
||||
columns: &'a mut Columns,
|
||||
col_id: usize,
|
||||
profiles: &'a mut NotesHolderStorage<Profile>,
|
||||
ndb: &'a Ndb,
|
||||
note_cache: &'a mut NoteCache,
|
||||
img_cache: &'a mut ImageCache,
|
||||
) -> Self {
|
||||
ProfileView {
|
||||
pubkey,
|
||||
timeline_id,
|
||||
columns,
|
||||
col_id,
|
||||
profiles,
|
||||
ndb,
|
||||
note_cache,
|
||||
img_cache,
|
||||
@@ -43,27 +43,32 @@ impl<'a> ProfileView<'a> {
|
||||
}
|
||||
|
||||
pub fn ui(&mut self, ui: &mut egui::Ui) -> TimelineResponse {
|
||||
let scroll_id = egui::Id::new(("profile_scroll", self.timeline_id, self.pubkey));
|
||||
let scroll_id = egui::Id::new(("profile_scroll", self.col_id, self.pubkey));
|
||||
|
||||
ScrollArea::vertical()
|
||||
.id_source(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 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, &txn, self.pubkey.bytes())
|
||||
.get_ptr();
|
||||
|
||||
TimelineView::new(
|
||||
self.timeline_id,
|
||||
self.columns,
|
||||
profile.timeline.selected_view = tabs_ui(ui);
|
||||
|
||||
TimelineTabView::new(
|
||||
profile.timeline.current_view(),
|
||||
false,
|
||||
false,
|
||||
&txn,
|
||||
self.ndb,
|
||||
self.note_cache,
|
||||
self.img_cache,
|
||||
false,
|
||||
)
|
||||
.ui_no_scroll(ui)
|
||||
.show(ui)
|
||||
})
|
||||
.inner
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ fn timeline_ui_no_scroll(
|
||||
.show(ui)
|
||||
}
|
||||
|
||||
fn tabs_ui(ui: &mut egui::Ui) -> i32 {
|
||||
pub fn tabs_ui(ui: &mut egui::Ui) -> i32 {
|
||||
ui.spacing_mut().item_spacing.y = 0.0;
|
||||
|
||||
let tab_res = egui_tabs::Tabs::new(2)
|
||||
|
||||
Reference in New Issue
Block a user