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)); } } 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"]}] 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; 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 + } } 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( 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 {