if no tophid, retain or reset

This commit is contained in:
Ted Unangst 2019-10-20 14:49:49 -04:00
parent c0d7cee48d
commit 7f1d3c7339
1 changed files with 8 additions and 2 deletions

10
web.go
View File

@ -767,8 +767,12 @@ func honkpage(w http.ResponseWriter, u *login.UserInfo, honks []*Honk, templinfo
}
reverbolate(userid, honks)
templinfo["Honks"] = honks
if templinfo["TopHID"] == nil && len(honks) > 0 {
templinfo["TopHID"] = honks[0].ID
if templinfo["TopHID"] == nil {
if len(honks) > 0 {
templinfo["TopHID"] = honks[0].ID
} else {
templinfo["TopHID"] = 0
}
}
err := readviews.Execute(w, "honkpage.html", templinfo)
if err != nil {
@ -1674,6 +1678,8 @@ func webhydra(w http.ResponseWriter, r *http.Request) {
}
if len(honks) > 0 {
templinfo["TopHID"] = honks[0].ID
} else {
templinfo["TopHID"] = wanted
}
reverbolate(userid, honks)
templinfo["Honks"] = honks