From 781b89af6131e0c6fecc811b0322014cc0a03314 Mon Sep 17 00:00:00 2001 From: makeworld Date: Tue, 17 Nov 2020 11:59:06 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A7=20Allow=20caching,=20increase=20cu?= =?UTF-8?q?rDay=20initial"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cache/page.go | 3 +-- display/feeds.go | 14 +++++++++----- feeds/feeds.go | 1 - 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/cache/page.go b/cache/page.go index e31135d..0175e2f 100644 --- a/cache/page.go +++ b/cache/page.go @@ -3,7 +3,6 @@ package cache import ( - "strings" "sync" "github.com/makeworld-the-better-one/amfora/structs" @@ -47,7 +46,7 @@ func removeURL(url string) { // If your page is larger than the max cache size, the provided page // will silently not be added to the cache. func AddPage(p *structs.Page) { - if p.URL == "" || strings.HasPrefix(p.URL, "about:") { + if p.URL == "" { // Just in case, these pages shouldn't be cached return } diff --git a/display/feeds.go b/display/feeds.go index 921eafd..e326c7a 100644 --- a/display/feeds.go +++ b/display/feeds.go @@ -25,7 +25,7 @@ func toLocalDay(t time.Time) time.Time { // Feeds displays the feeds page on the current tab. func Feeds(t *tab) { - // Retrieve cached version if there hasn't been updates + // Retrieve cached version if there hasn't been any updates p, ok := cache.GetPage("about:feeds") if feedPageUpdated.After(feeds.LastUpdated) && ok { setPage(t, p) @@ -35,10 +35,14 @@ func Feeds(t *tab) { // curDay represents what day of posts the loop is on. // It only goes backwards in time. - // It's initial setting means: - // Only display posts older than 6 hours in the future, - // nothing further in the future. - curDay := toLocalDay(time.Now()).Add(6 * time.Hour) + // Its initial setting means: + // Only display posts older than 26 hours in the future, nothing further in the future. + // + // 26 hours was chosen because it is the largest timezone difference + // currently in the world. Posts may be dated in the future + // due to software bugs, where the local user's date is used, but + // the UTC timezone is specified. I believe gemfeed does this. + curDay := toLocalDay(time.Now()).Add(26 * time.Hour) pe := feeds.GetPageEntries() diff --git a/feeds/feeds.go b/feeds/feeds.go index c4c4986..5ac320a 100644 --- a/feeds/feeds.go +++ b/feeds/feeds.go @@ -329,6 +329,5 @@ func GetPageEntries() *PageEntries { data.RUnlock() sort.Sort(&pe) - return &pe }