use TimelineUnits instead of Vec<NoteRef>
Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
@@ -2,7 +2,10 @@ use egui::{vec2, Align, Color32, CornerRadius, RichText, Stroke, TextEdit};
|
||||
use enostr::{NoteId, Pubkey};
|
||||
use state::TypingType;
|
||||
|
||||
use crate::{timeline::TimelineTab, ui::timeline::TimelineTabView};
|
||||
use crate::{
|
||||
timeline::{TimelineTab, TimelineUnits},
|
||||
ui::timeline::TimelineTabView,
|
||||
};
|
||||
use egui_winit::clipboard::Clipboard;
|
||||
use nostrdb::{Filter, Ndb, Transaction};
|
||||
use notedeck::{tr, tr_plural, JobsCache, Localization, NoteAction, NoteContext, NoteRef};
|
||||
@@ -125,7 +128,7 @@ impl<'a, 'd> SearchView<'a, 'd> {
|
||||
"Got {count} result for '{query}'", // one
|
||||
"Got {count} results for '{query}'", // other
|
||||
"Search results count", // comment
|
||||
self.query.notes.notes.len(), // count
|
||||
self.query.notes.units.len(), // count
|
||||
query = &self.query.string
|
||||
));
|
||||
note_action = self.show_search_results(ui);
|
||||
@@ -190,7 +193,7 @@ fn execute_search(
|
||||
return;
|
||||
};
|
||||
|
||||
tab.notes = note_refs;
|
||||
tab.units = TimelineUnits::from_refs_single(note_refs);
|
||||
tab.list.borrow_mut().reset();
|
||||
ctx.request_repaint();
|
||||
}
|
||||
|
||||
@@ -415,57 +415,30 @@ impl<'a, 'd> TimelineTabView<'a, 'd> {
|
||||
|
||||
pub fn show(&mut self, ui: &mut egui::Ui) -> Option<NoteAction> {
|
||||
let mut action: Option<NoteAction> = None;
|
||||
let len = self.tab.notes.len();
|
||||
let len = self.tab.units.len();
|
||||
|
||||
let is_muted = self.note_context.accounts.mutefun();
|
||||
let mute = self.note_context.accounts.mute();
|
||||
|
||||
self.tab
|
||||
.list
|
||||
.borrow_mut()
|
||||
.ui_custom_layout(ui, len, |ui, start_index| {
|
||||
.ui_custom_layout(ui, len, |ui, index| {
|
||||
// tracing::info!("rendering index: {index}");
|
||||
ui.spacing_mut().item_spacing.y = 0.0;
|
||||
ui.spacing_mut().item_spacing.x = 4.0;
|
||||
|
||||
let ind = if self.reversed {
|
||||
len - start_index - 1
|
||||
} else {
|
||||
start_index
|
||||
let Some(entry) = self.tab.units.get(index) else {
|
||||
return 0;
|
||||
};
|
||||
|
||||
let note_key = self.tab.notes[ind].key;
|
||||
match self.render_entry(ui, entry, &mute) {
|
||||
RenderEntryResponse::Unsuccessful => return 0,
|
||||
|
||||
let note =
|
||||
if let Ok(note) = self.note_context.ndb.get_note_by_key(self.txn, note_key) {
|
||||
note
|
||||
} else {
|
||||
warn!("failed to query note {:?}", note_key);
|
||||
return 0;
|
||||
};
|
||||
|
||||
// should we mute the thread? we might not have it!
|
||||
let muted = if let Ok(root_id) = root_note_id_from_selected_id(
|
||||
self.note_context.ndb,
|
||||
self.note_context.note_cache,
|
||||
self.txn,
|
||||
note.id(),
|
||||
) {
|
||||
is_muted(¬e, root_id.bytes())
|
||||
} else {
|
||||
false
|
||||
};
|
||||
|
||||
if !muted {
|
||||
notedeck_ui::padding(8.0, ui, |ui| {
|
||||
let resp =
|
||||
NoteView::new(self.note_context, ¬e, self.note_options, self.jobs)
|
||||
.show(ui);
|
||||
|
||||
if let Some(note_action) = resp.action {
|
||||
action = Some(note_action)
|
||||
RenderEntryResponse::Success(note_action) => {
|
||||
if let Some(cur_action) = note_action {
|
||||
action = Some(cur_action);
|
||||
}
|
||||
});
|
||||
|
||||
notedeck_ui::hline(ui);
|
||||
}
|
||||
}
|
||||
|
||||
1
|
||||
|
||||
Reference in New Issue
Block a user