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