notedeck

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

commit 232ba0e3aabb2477dec2d68cc3d1111275e9b694
parent a8693a2bd3116a776d0ac0e540fcd2d6294f8f38
Author: William Casarin <jb55@jb55.com>
Date:   Thu, 23 May 2024 14:16:43 -0700

list: switch from arc mutext to rc refcell

we don't have any multithreaded stuff yet

Signed-off-by: William Casarin <jb55@jb55.com>

Diffstat:
Msrc/app.rs | 4+---
Msrc/timeline.rs | 10+++++-----
2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/src/app.rs b/src/app.rs @@ -309,9 +309,7 @@ fn poll_notes_for_timeline<'a>( timeline .current_view() .list - .clone() - .lock() - .unwrap() + .borrow_mut() .items_inserted_at_start(new_items); } diff --git a/src/timeline.rs b/src/timeline.rs @@ -7,8 +7,9 @@ use egui_tabs::TabColor; use egui_virtual_list::VirtualList; use enostr::Filter; use nostrdb::{Note, NoteKey, Subscription, Transaction}; +use std::cell::RefCell; use std::cmp::Ordering; -use std::sync::{Arc, Mutex}; +use std::rc::Rc; use tracing::warn; @@ -70,13 +71,13 @@ pub struct TimelineView { pub notes: Vec<NoteRef>, pub selection: i32, pub filter: ViewFilter, - pub list: Arc<Mutex<VirtualList>>, + pub list: Rc<RefCell<VirtualList>>, } impl TimelineView { pub fn new(filter: ViewFilter) -> Self { let selection = 0i32; - let list = Arc::new(Mutex::new(VirtualList::new())); + let list = Rc::new(RefCell::new(VirtualList::new())); let notes: Vec<NoteRef> = Vec::with_capacity(1000); TimelineView { @@ -247,8 +248,7 @@ pub fn timeline_view(ui: &mut egui::Ui, app: &mut Damus, timeline: usize) { let view = app.timelines[timeline].current_view(); let len = view.notes.len(); let list = view.list.clone(); - list.lock() - .unwrap() + list.borrow_mut() .ui_custom_layout(ui, len, |ui, start_index| { ui.spacing_mut().item_spacing.y = 0.0; ui.spacing_mut().item_spacing.x = 4.0;