Scrollbar position no longer shared between the four different feeds

This commit is contained in:
Mike Dilger 2023-01-23 07:21:08 +13:00
parent d307dcc6fb
commit 5a00d00400

View File

@ -65,7 +65,7 @@ pub(super) fn update(app: &mut GossipUi, ctx: &Context, frame: &mut eframe::Fram
match feed_kind { match feed_kind {
FeedKind::General => { FeedKind::General => {
let feed = GLOBALS.feed.get_general(); let feed = GLOBALS.feed.get_general();
render_a_feed(app, ctx, frame, ui, feed, false); render_a_feed(app, ctx, frame, ui, feed, false, "general");
} }
FeedKind::Replies => { FeedKind::Replies => {
if GLOBALS.signer.blocking_read().public_key().is_none() { if GLOBALS.signer.blocking_read().public_key().is_none() {
@ -78,16 +78,16 @@ pub(super) fn update(app: &mut GossipUi, ctx: &Context, frame: &mut eframe::Fram
}); });
} }
let feed = GLOBALS.feed.get_replies(); let feed = GLOBALS.feed.get_replies();
render_a_feed(app, ctx, frame, ui, feed, false); render_a_feed(app, ctx, frame, ui, feed, false, "replies");
} }
FeedKind::Thread { .. } => { FeedKind::Thread { id, .. } => {
if let Some(parent) = GLOBALS.feed.get_thread_parent() { if let Some(parent) = GLOBALS.feed.get_thread_parent() {
render_a_feed(app, ctx, frame, ui, vec![parent], true); render_a_feed(app, ctx, frame, ui, vec![parent], true, &id.as_hex_string());
} }
} }
FeedKind::Person(pubkeyhex) => { FeedKind::Person(pubkeyhex) => {
let feed = GLOBALS.feed.get_person_feed(pubkeyhex); let feed = GLOBALS.feed.get_person_feed(pubkeyhex.clone());
render_a_feed(app, ctx, frame, ui, feed, false); render_a_feed(app, ctx, frame, ui, feed, false, &pubkeyhex.0);
} }
} }
} }
@ -222,30 +222,33 @@ fn render_a_feed(
ui: &mut Ui, ui: &mut Ui,
feed: Vec<Id>, feed: Vec<Id>,
threaded: bool, threaded: bool,
scroll_area_id: &str,
) { ) {
ScrollArea::vertical().show(ui, |ui| { ScrollArea::vertical()
let bgcolor = if ctx.style().visuals.dark_mode { .id_source(scroll_area_id)
Color32::BLACK .show(ui, |ui| {
} else { let bgcolor = if ctx.style().visuals.dark_mode {
Color32::WHITE Color32::BLACK
}; } else {
Frame::none().fill(bgcolor).show(ui, |ui| { Color32::WHITE
for id in feed.iter() { };
render_post_maybe_fake( Frame::none().fill(bgcolor).show(ui, |ui| {
app, for id in feed.iter() {
ctx, render_post_maybe_fake(
frame, app,
ui, ctx,
FeedPostParams { frame,
id: *id, ui,
indent: 0, FeedPostParams {
as_reply_to: false, id: *id,
threaded, indent: 0,
}, as_reply_to: false,
); threaded,
} },
);
}
});
}); });
});
} }
fn render_post_maybe_fake( fn render_post_maybe_fake(
@ -525,9 +528,7 @@ fn render_post_actual(
// Possible subject line // Possible subject line
if let Some(subject) = event.subject() { if let Some(subject) = event.subject() {
ui.label( ui.label(RichText::new(subject).strong().underline());
RichText::new(subject).strong().underline()
);
} }
// MAIN CONTENT // MAIN CONTENT