mirror of
https://github.com/mikedilger/gossip.git
synced 2024-09-19 19:46:50 +00:00
Use more sensible time ranges (still this is temporary as that is going away very soon)
This commit is contained in:
parent
6beb2ba673
commit
87510563d0
@ -37,6 +37,16 @@ impl std::fmt::Display for FeedKind {
|
||||
}
|
||||
|
||||
impl FeedKind {
|
||||
pub fn simple_string(&self) -> &'static str {
|
||||
match self {
|
||||
Self::List(_, _) => "list",
|
||||
Self::Inbox(_) => "inbox",
|
||||
Self::Thread { .. } => "thread",
|
||||
Self::Person(_) => "person",
|
||||
Self::DmChat(_) => "dmchat",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn can_load_more(&self) -> bool {
|
||||
match self {
|
||||
Self::List(_, _) => true,
|
||||
|
@ -51,7 +51,16 @@ impl Feed {
|
||||
/// This only looks further back in stored events, it doesn't deal with minion subscriptions.
|
||||
pub(crate) fn load_more(&self) -> Unixtime {
|
||||
let mut start = *self.current_feed_start.read();
|
||||
start = start - Duration::from_secs(43200);
|
||||
|
||||
let kindstr = self.current_feed_kind.read().simple_string();
|
||||
let dur = if kindstr == "person" {
|
||||
60 * 60 * 24 * 15
|
||||
} else if kindstr == "inbox" {
|
||||
60 * 60 * 24 * 7
|
||||
} else {
|
||||
60 * 60 * 4
|
||||
};
|
||||
start = start - Duration::from_secs(dur);
|
||||
*self.current_feed_start.write() = start;
|
||||
start
|
||||
}
|
||||
@ -85,12 +94,21 @@ impl Feed {
|
||||
}
|
||||
|
||||
pub fn switch_feed(&self, feed_kind: FeedKind) {
|
||||
let kindstr = feed_kind.simple_string();
|
||||
|
||||
// NOTE: do not clear the feed here, or the UI will get an empty feed momentarily
|
||||
// and the scroll bar "memory" will be reset to the top. Let recompute rebuild
|
||||
// the feed (called down below)
|
||||
|
||||
// Reset the feed start
|
||||
*self.current_feed_start.write() = Unixtime::now().unwrap() - Duration::from_secs(43200);
|
||||
let dur = if kindstr == "person" {
|
||||
60 * 60 * 24 * 15
|
||||
} else if kindstr == "inbox" {
|
||||
60 * 60 * 24 * 7
|
||||
} else {
|
||||
60 * 60 * 4
|
||||
};
|
||||
*self.current_feed_start.write() = Unixtime::now().unwrap() - Duration::from_secs(dur);
|
||||
|
||||
// Reset the feed thread
|
||||
*self.thread_parent.write() = if let FeedKind::Thread {
|
||||
|
@ -661,7 +661,7 @@ impl Minion {
|
||||
// to get their events over the past chunk.
|
||||
Unixtime::now().unwrap()
|
||||
} else {
|
||||
let since = self.compute_since();
|
||||
let since = self.compute_since(60 * 60 * 4);
|
||||
self.general_feed_start = Some(since);
|
||||
since
|
||||
}
|
||||
@ -706,7 +706,7 @@ impl Minion {
|
||||
if !new_keys.is_empty() {
|
||||
let since = match self.general_feed_start {
|
||||
Some(start) => start,
|
||||
None => self.compute_since(),
|
||||
None => self.compute_since(60 * 60 * 4),
|
||||
};
|
||||
|
||||
let filters = filter_fns::general_feed(&new_keys, FeedRange::After { since });
|
||||
@ -731,7 +731,7 @@ impl Minion {
|
||||
}
|
||||
|
||||
// Compute how far to look back
|
||||
let replies_since = self.compute_since();
|
||||
let replies_since = self.compute_since(60 * 60 * 24 * 7);
|
||||
self.inbox_feed_start = Some(replies_since);
|
||||
|
||||
let spamsafe = self.dbrelay.has_usage_bits(Relay::SPAMSAFE);
|
||||
@ -766,7 +766,7 @@ impl Minion {
|
||||
|
||||
// Subscribe to the user's config (config, DMs, etc) which is on their own write relays
|
||||
async fn subscribe_config(&mut self, job_id: u64) -> Result<(), Error> {
|
||||
let since = self.compute_since();
|
||||
let since = self.compute_since(60 * 60 * 24 * 15);
|
||||
|
||||
let filters = filter_fns::config(since);
|
||||
|
||||
@ -799,7 +799,7 @@ impl Minion {
|
||||
async fn subscribe_person_feed(&mut self, job_id: u64, pubkey: PublicKey) -> Result<(), Error> {
|
||||
// NOTE we do not unsubscribe to the general feed
|
||||
|
||||
let since = self.compute_since();
|
||||
let since = self.compute_since(60 * 60 * 24 * 15);
|
||||
self.person_feed_start = Some(since);
|
||||
|
||||
let filters = filter_fns::person_feed(pubkey, FeedRange::After { since });
|
||||
@ -1320,10 +1320,10 @@ impl Minion {
|
||||
}
|
||||
}
|
||||
|
||||
fn compute_since(&self) -> Unixtime {
|
||||
fn compute_since(&self, chunk_seconds: u64) -> Unixtime {
|
||||
let now = Unixtime::now().unwrap();
|
||||
let overlap = Duration::from_secs(GLOBALS.storage.read_setting_overlap());
|
||||
let chunk = Duration::from_secs(43200);
|
||||
let chunk = Duration::from_secs(chunk_seconds);
|
||||
|
||||
// FIXME - general subscription EOSE is not necessarily applicable to
|
||||
// other subscriptions. BUt we don't record when we got an EOSE
|
||||
|
Loading…
Reference in New Issue
Block a user