🚧 Allow caching, increase curDay initial"

This commit is contained in:
makeworld 2020-11-17 11:59:06 -05:00
parent 0a963a0d8d
commit 781b89af61
3 changed files with 10 additions and 8 deletions

3
cache/page.go vendored
View File

@ -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
}

View File

@ -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()

View File

@ -329,6 +329,5 @@ func GetPageEntries() *PageEntries {
data.RUnlock()
sort.Sort(&pe)
return &pe
}