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
··· 224 224 } 225 225 226 226 func (s *State) Home(w http.ResponseWriter, r *http.Request) { 227 - timeline, err := db.MakeTimeline(s.db, 15) 227 + timeline, err := db.MakeTimeline(s.db, 5) 228 228 if err != nil { 229 229 log.Println(err) 230 230 s.pages.Notice(w, "timeline", "Uh oh! Failed to load timeline.") ··· 238 238 return 239 239 } 240 240 241 - timeline = timeline[:5] 242 - 243 241 s.pages.Home(w, pages.TimelineParams{ 244 242 LoggedInUser: nil, 245 243 Timeline: timeline,