appview/state: fix timeline out of bounds #555

merged
opened by isuggest.selfce.st targeting master from isuggest.selfce.st/core: patch/timeline-fix

When running a local dev copy of the appview, the timeline isn't properly populated if only running the appview. This causes db.MakeTimeline to give an empty array. Thus, slicing it down to 5 elements results in an out of bounds error.

This PR removes the slice and simply limits the timeline view to 5 elements down from 15.

Changed files
+1 -3
appview
state
+1 -3
appview/state/state.go
···
}
func (s *State) Home(w http.ResponseWriter, r *http.Request) {
-
timeline, err := db.MakeTimeline(s.db, 15)
+
timeline, err := db.MakeTimeline(s.db, 5)
if err != nil {
log.Println(err)
s.pages.Notice(w, "timeline", "Uh oh! Failed to load timeline.")
···
return
}
-
timeline = timeline[:5]
-
s.pages.Home(w, pages.TimelineParams{
LoggedInUser: nil,
Timeline: timeline,