mirror of
https://github.com/mikedilger/gossip.git
synced 2024-09-29 16:31:18 +00:00
New event tracking is now ID based, and turned off if your mouse-pointer hovers over it
This commit is contained in:
parent
1cda929af6
commit
1922a0c98c
@ -1,25 +1,22 @@
|
||||
use crate::error::Error;
|
||||
use crate::globals::GLOBALS;
|
||||
use async_recursion::async_recursion;
|
||||
use dashmap::{DashMap, DashSet};
|
||||
use dashmap::DashMap;
|
||||
use nostr_types::{Event, Id};
|
||||
use tokio::task;
|
||||
|
||||
pub struct Events {
|
||||
events: DashMap<Id, Event>,
|
||||
new_events: DashSet<Id>,
|
||||
}
|
||||
|
||||
impl Events {
|
||||
pub fn new() -> Events {
|
||||
Events {
|
||||
events: DashMap::new(),
|
||||
new_events: DashSet::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn insert(&self, event: Event) {
|
||||
let _ = self.new_events.insert(event.id);
|
||||
let _ = self.events.insert(event.id, event);
|
||||
}
|
||||
|
||||
@ -80,14 +77,6 @@ impl Events {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_new(&self, id: &Id) -> bool {
|
||||
self.new_events.contains(id)
|
||||
}
|
||||
|
||||
pub fn clear_new(&self) {
|
||||
self.new_events.clear();
|
||||
}
|
||||
|
||||
pub fn iter(&self) -> dashmap::iter::Iter<Id, Event> {
|
||||
self.events.iter()
|
||||
}
|
||||
|
@ -549,9 +549,6 @@ impl Overlord {
|
||||
self.pick_relays().await;
|
||||
}
|
||||
ToOverlordMessage::ProcessIncomingEvents => {
|
||||
// Clear new events
|
||||
GLOBALS.events.clear_new();
|
||||
|
||||
std::mem::drop(tokio::spawn(async move {
|
||||
for (event, url, sub) in GLOBALS.incoming_events.write().await.drain(..) {
|
||||
let _ =
|
||||
|
@ -57,7 +57,6 @@ pub(super) fn update(app: &mut GossipUi, ctx: &Context, frame: &mut eframe::Fram
|
||||
.clicked()
|
||||
{
|
||||
app.set_page(Page::Feed(feed_kind.clone()));
|
||||
GLOBALS.events.clear_new();
|
||||
}
|
||||
}
|
||||
if matches!(feed_kind, FeedKind::Person(..)) {
|
||||
@ -70,7 +69,6 @@ pub(super) fn update(app: &mut GossipUi, ctx: &Context, frame: &mut eframe::Fram
|
||||
.clicked()
|
||||
{
|
||||
app.set_page(Page::Feed(feed_kind.clone()));
|
||||
GLOBALS.events.clear_new();
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -260,18 +258,18 @@ fn render_post_actual(
|
||||
};
|
||||
|
||||
#[allow(clippy::collapsible_else_if)]
|
||||
let bgcolor = if GLOBALS.events.is_new(&event.id) {
|
||||
if ctx.style().visuals.dark_mode {
|
||||
Color32::from_rgb(60, 0, 0)
|
||||
} else {
|
||||
Color32::LIGHT_YELLOW
|
||||
}
|
||||
} else {
|
||||
let bgcolor = if app.viewed.contains(&event.id) {
|
||||
if ctx.style().visuals.dark_mode {
|
||||
Color32::BLACK
|
||||
} else {
|
||||
Color32::WHITE
|
||||
}
|
||||
} else {
|
||||
if ctx.style().visuals.dark_mode {
|
||||
Color32::from_rgb(60, 0, 0)
|
||||
} else {
|
||||
Color32::LIGHT_YELLOW
|
||||
}
|
||||
};
|
||||
|
||||
let is_main_event: bool = {
|
||||
@ -282,7 +280,7 @@ fn render_post_actual(
|
||||
}
|
||||
};
|
||||
|
||||
Frame::none().fill(bgcolor).show(ui, |ui| {
|
||||
let inner_response = Frame::none().fill(bgcolor).show(ui, |ui| {
|
||||
if is_main_event {
|
||||
thin_red_separator(ui);
|
||||
}
|
||||
@ -311,6 +309,10 @@ fn render_post_actual(
|
||||
}
|
||||
});
|
||||
|
||||
if inner_response.response.hovered() {
|
||||
app.viewed.insert(id);
|
||||
}
|
||||
|
||||
ui.separator();
|
||||
|
||||
if threaded && !as_reply_to {
|
||||
|
@ -15,6 +15,7 @@ use crate::globals::GLOBALS;
|
||||
use crate::people::DbPerson;
|
||||
use crate::settings::Settings;
|
||||
use crate::ui::widgets::CopyButton;
|
||||
use dashmap::DashSet;
|
||||
use eframe::{egui, IconData, Theme};
|
||||
use egui::{
|
||||
Color32, ColorImage, Context, Image, ImageData, Label, RichText, SelectableLabel, Sense,
|
||||
@ -88,6 +89,7 @@ struct GossipUi {
|
||||
// Post rendering
|
||||
render_raw: Option<Id>,
|
||||
render_qr: Option<Id>,
|
||||
viewed: DashSet<Id>,
|
||||
|
||||
// Person page rendering ('npub', 'nprofile', or 'lud06')
|
||||
person_qr: Option<&'static str>,
|
||||
@ -229,6 +231,7 @@ impl GossipUi {
|
||||
qr_codes: HashMap::new(),
|
||||
render_raw: None,
|
||||
render_qr: None,
|
||||
viewed: DashSet::new(),
|
||||
person_qr: None,
|
||||
setting_active_person: false,
|
||||
page: start_page,
|
||||
@ -288,11 +291,9 @@ impl GossipUi {
|
||||
match &page {
|
||||
Page::Feed(FeedKind::General) => {
|
||||
GLOBALS.feed.set_feed_to_general();
|
||||
GLOBALS.events.clear_new();
|
||||
}
|
||||
Page::Feed(FeedKind::Replies) => {
|
||||
GLOBALS.feed.set_feed_to_replies();
|
||||
GLOBALS.events.clear_new();
|
||||
}
|
||||
Page::Feed(FeedKind::Thread { id, referenced_by }) => {
|
||||
GLOBALS.feed.set_feed_to_thread(*id, *referenced_by);
|
||||
@ -349,7 +350,6 @@ impl eframe::App for GossipUi {
|
||||
.clicked()
|
||||
{
|
||||
self.set_page(Page::Feed(FeedKind::General));
|
||||
GLOBALS.events.clear_new();
|
||||
}
|
||||
ui.separator();
|
||||
if ui
|
||||
|
Loading…
Reference in New Issue
Block a user