From 0a6a44104131e2ec29286e51a800d05471e1a150 Mon Sep 17 00:00:00 2001 From: William Casarin Date: Mon, 29 Apr 2024 11:00:56 -0700 Subject: [PATCH 1/6] simplify is_mobile check Just base it on the current compile target Signed-off-by: William Casarin --- src/ui/mod.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/ui/mod.rs b/src/ui/mod.rs index 2ddbe4b1..0a377b2b 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -36,8 +36,14 @@ pub fn padding( .show(ui, add_contents) } -pub fn is_mobile(ctx: &egui::Context) -> bool { - //true - let screen_size = ctx.screen_rect().size(); - screen_size.x < 550.0 +#[inline] +pub fn is_mobile(_ctx: &egui::Context) -> bool { + #[cfg(any(target_os = "android", target_os = "ios"))] + { + true + } + #[cfg(not(any(target_os = "android", target_os = "ios")))] + { + false + } } From ca58b831b611fa7941e37052da33c394efa1dd60 Mon Sep 17 00:00:00 2001 From: William Casarin Date: Mon, 29 Apr 2024 11:01:28 -0700 Subject: [PATCH 2/6] queries: set reasonable initial query sizes Signed-off-by: William Casarin --- queries/global.json | 2 +- queries/notifications.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/queries/global.json b/queries/global.json index c54860c3..a1311cba 100644 --- a/queries/global.json +++ b/queries/global.json @@ -1 +1 @@ -[{"limit": 10, "kinds":[1]}] +[{"limit": 100, "kinds":[1]}] diff --git a/queries/notifications.json b/queries/notifications.json index 35bc9e5c..650236db 100644 --- a/queries/notifications.json +++ b/queries/notifications.json @@ -1 +1 @@ -[{"limit": 1000, "kinds":[1], "#p": ["32e1827635450ebb3c5a7d12c1f8e7b2b514439ac10a67eef3d9fd9c5c68e245"]}] +[{"limit": 100, "kinds":[1], "#p": ["32e1827635450ebb3c5a7d12c1f8e7b2b514439ac10a67eef3d9fd9c5c68e245"]}] From a173e38141a2ddd4d3542517f57a3fe59d99d0c5 Mon Sep 17 00:00:00 2001 From: William Casarin Date: Mon, 29 Apr 2024 12:47:29 -0700 Subject: [PATCH 3/6] slightly larger pfpfs Signed-off-by: William Casarin --- src/ui/profile/picture.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ui/profile/picture.rs b/src/ui/profile/picture.rs index 40998ea2..50b55460 100644 --- a/src/ui/profile/picture.rs +++ b/src/ui/profile/picture.rs @@ -21,7 +21,7 @@ impl<'cache, 'url> ProfilePic<'cache, 'url> { } pub fn default_size() -> f32 { - 32.0 + 38.0 } pub fn no_pfp_url() -> &'static str { From 632e5b89d14e40b05e3dea8732f8cfaff71d73b4 Mon Sep 17 00:00:00 2001 From: William Casarin Date: Mon, 29 Apr 2024 12:48:26 -0700 Subject: [PATCH 4/6] mobile: don't add hover on mobile Signed-off-by: William Casarin --- src/ui/note/mod.rs | 50 +++++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/src/ui/note/mod.rs b/src/ui/note/mod.rs index 0bdf40e0..86effccd 100644 --- a/src/ui/note/mod.rs +++ b/src/ui/note/mod.rs @@ -4,7 +4,7 @@ pub mod options; pub use contents::NoteContents; pub use options::NoteOptions; -use crate::{colors, ui, Damus}; +use crate::{colors, ui, ui::is_mobile, Damus}; use egui::{Label, RichText, Sense}; use nostrdb::{NoteKey, Transaction}; use std::hash::{Hash, Hasher}; @@ -207,28 +207,32 @@ impl<'a> Note<'a> { let profile_key = profile.as_ref().unwrap().record().note_key(); let note_key = note_key.as_u64(); - let (rect, size) = ui::anim::hover_expand( - ui, - egui::Id::new(ProfileAnimId { - profile_key, - note_key, - }), - ui::ProfilePic::default_size(), - expand_size, - anim_speed, - ); - - ui.put( - rect, - ui::ProfilePic::new(&mut self.app.img_cache, pic).size(size), - ) - .on_hover_ui_at_pointer(|ui| { - ui.set_max_width(300.0); - ui.add(ui::ProfilePreview::new( - profile.as_ref().unwrap(), - &mut self.app.img_cache, - )); - }); + if is_mobile(ui.ctx()) { + ui.add(ui::ProfilePic::new(&mut self.app.img_cache, pic)); + } else { + let (rect, size) = ui::anim::hover_expand( + ui, + egui::Id::new(ProfileAnimId { + profile_key, + note_key, + }), + ui::ProfilePic::default_size(), + expand_size, + anim_speed, + ); + + ui.put( + rect, + ui::ProfilePic::new(&mut self.app.img_cache, pic).size(size), + ) + .on_hover_ui_at_pointer(|ui| { + ui.set_max_width(300.0); + ui.add(ui::ProfilePreview::new( + profile.as_ref().unwrap(), + &mut self.app.img_cache, + )); + }); + } } None => { ui.add(ui::ProfilePic::new( From f4d496012be57e68264a88e3d60265f6d50d1d37 Mon Sep 17 00:00:00 2001 From: William Casarin Date: Mon, 29 Apr 2024 14:05:43 -0700 Subject: [PATCH 5/6] log relay subscriptions Signed-off-by: William Casarin --- enostr/src/relay/mod.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/enostr/src/relay/mod.rs b/enostr/src/relay/mod.rs index 8a88efbf..5d4f08eb 100644 --- a/enostr/src/relay/mod.rs +++ b/enostr/src/relay/mod.rs @@ -1,6 +1,7 @@ use ewebsock::{WsMessage, WsReceiver, WsSender}; use crate::{ClientMessage, Filter, Result}; +use log::info; use std::fmt; use std::hash::{Hash, Hasher}; @@ -77,6 +78,10 @@ impl Relay { } pub fn subscribe(&mut self, subid: String, filters: Vec) { + info!( + "sending '{}' subscription to relay pool: {:?}", + subid, filters + ); self.send(&ClientMessage::req(subid, filters)); } } From d9f1582ee7ff7ac30c0ddd20e350cc20f34be8bc Mon Sep 17 00:00:00 2001 From: William Casarin Date: Thu, 18 Apr 2024 08:38:52 -0700 Subject: [PATCH 6/6] since filter optimization This is an optimization that allows us to modify our network filter to include since-information based off of our local relay. The idea is to look at the latest note in a given view, and add that to the since filter for the remote query. Fixes: https://github.com/damus-io/notedeck/issues/36 Signed-off-by: William Casarin --- src/app.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/app.rs b/src/app.rs index c4aadb17..d4a4d07f 100644 --- a/src/app.rs +++ b/src/app.rs @@ -70,6 +70,20 @@ fn relay_setup(pool: &mut RelayPool, ctx: &egui::Context) { } } +fn since_optimize_filter(filter: &mut enostr::Filter, notes: &[NoteRef]) { + // Get the latest entry in the events + if notes.is_empty() { + return; + } + + // get the latest note + let latest = notes[0]; + let since = latest.created_at - 60; + + // update the filters + filter.since = Some(since); +} + fn send_initial_filters(damus: &mut Damus, relay_url: &str) { info!("Sending initial filters to {}", relay_url); let mut c: u32 = 1; @@ -78,7 +92,11 @@ fn send_initial_filters(damus: &mut Damus, relay_url: &str) { let relay = &mut relay.relay; if relay.url == relay_url { for timeline in &damus.timelines { - relay.subscribe(format!("initial{}", c), timeline.filter.clone()); + let mut filter = timeline.filter.clone(); + for f in &mut filter { + since_optimize_filter(f, &timeline.notes); + } + relay.subscribe(format!("initial{}", c), filter); c += 1; } return;