fix refreshing pages with reversed order
This commit is contained in:
parent
75fdc3a5f4
commit
5916ae68ab
|
@ -1109,6 +1109,7 @@ var oldjonks = cacheNew(cacheOptions{Filler: func(xid string) ([]byte, bool) {
|
||||||
}
|
}
|
||||||
user, _ := butwhatabout(honk.Username)
|
user, _ := butwhatabout(honk.Username)
|
||||||
rawhonks := gethonksbyconvoy(honk.UserID, honk.Convoy)
|
rawhonks := gethonksbyconvoy(honk.UserID, honk.Convoy)
|
||||||
|
reversehonks(rawhonks)
|
||||||
for _, h := range rawhonks {
|
for _, h := range rawhonks {
|
||||||
if h.RID == honk.XID && h.Public && (h.Whofore == 2 || h.IsAcked()) {
|
if h.RID == honk.XID && h.Public && (h.Whofore == 2 || h.IsAcked()) {
|
||||||
honk.Replies = append(honk.Replies, h)
|
honk.Replies = append(honk.Replies, h)
|
||||||
|
|
|
@ -159,9 +159,6 @@ func gethonksbycombo(userid int64, combo string) []*Honk {
|
||||||
func gethonksbyconvoy(userid int64, convoy string) []*Honk {
|
func gethonksbyconvoy(userid int64, convoy string) []*Honk {
|
||||||
rows, err := stmtHonksByConvoy.Query(userid, userid, convoy)
|
rows, err := stmtHonksByConvoy.Query(userid, userid, convoy)
|
||||||
honks := getsomehonks(rows, err)
|
honks := getsomehonks(rows, err)
|
||||||
for i, j := 0, len(honks)-1; i < j; i, j = i+1, j-1 {
|
|
||||||
honks[i], honks[j] = honks[j], honks[i]
|
|
||||||
}
|
|
||||||
return honks
|
return honks
|
||||||
}
|
}
|
||||||
func gethonksbysearch(userid int64, q string) []*Honk {
|
func gethonksbysearch(userid int64, q string) []*Honk {
|
||||||
|
@ -176,6 +173,12 @@ func gethonksbyontology(userid int64, name string) []*Honk {
|
||||||
return honks
|
return honks
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func reversehonks(honks []*Honk) {
|
||||||
|
for i, j := 0, len(honks)-1; i < j; i, j = i+1, j-1 {
|
||||||
|
honks[i], honks[j] = honks[j], honks[i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func getsomehonks(rows *sql.Rows, err error) []*Honk {
|
func getsomehonks(rows *sql.Rows, err error) []*Honk {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("error querying honks: %s", err)
|
log.Printf("error querying honks: %s", err)
|
||||||
|
|
|
@ -76,11 +76,21 @@ function fillinhonks(xhr) {
|
||||||
}
|
}
|
||||||
srvel.prepend(srvmsg)
|
srvel.prepend(srvmsg)
|
||||||
|
|
||||||
|
var frontload = true
|
||||||
|
if (curpagestate.name == "convoy") {
|
||||||
|
frontload = false
|
||||||
|
}
|
||||||
|
|
||||||
var honksonpage = document.getElementById("honksonpage")
|
var honksonpage = document.getElementById("honksonpage")
|
||||||
var holder = honksonpage.children[0]
|
var holder = honksonpage.children[0]
|
||||||
var lenhonks = honks.length
|
var lenhonks = honks.length
|
||||||
for (var i = honks.length; i > 0; i--) {
|
for (var i = honks.length; i > 0; i--) {
|
||||||
|
if (frontload) {
|
||||||
holder.prepend(honks[i-1])
|
holder.prepend(honks[i-1])
|
||||||
|
} else {
|
||||||
|
holder.append(honks[i-1])
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
relinklinks()
|
relinklinks()
|
||||||
return lenhonks
|
return lenhonks
|
||||||
|
@ -157,9 +167,7 @@ function pageswitcher(name, arg) {
|
||||||
return function(evt) {
|
return function(evt) {
|
||||||
var topmenu = document.getElementById("topmenu")
|
var topmenu = document.getElementById("topmenu")
|
||||||
topmenu.open = false
|
topmenu.open = false
|
||||||
console.log("switching to", name +":"+arg)
|
|
||||||
if (name == curpagestate.name && arg == curpagestate.arg) {
|
if (name == curpagestate.name && arg == curpagestate.arg) {
|
||||||
console.log("skipping nav")
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
switchtopage(name, arg)
|
switchtopage(name, arg)
|
||||||
|
|
15
web.go
15
web.go
|
@ -579,6 +579,7 @@ func showhonker(w http.ResponseWriter, r *http.Request) {
|
||||||
msg := fmt.Sprintf(`honks by honker: <a href="%s" ref="noreferrer">%s</a>`, name, name)
|
msg := fmt.Sprintf(`honks by honker: <a href="%s" ref="noreferrer">%s</a>`, name, name)
|
||||||
templinfo := getInfo(r)
|
templinfo := getInfo(r)
|
||||||
templinfo["PageName"] = "honker"
|
templinfo["PageName"] = "honker"
|
||||||
|
templinfo["PageArg"] = name
|
||||||
templinfo["ServerMessage"] = template.HTML(msg)
|
templinfo["ServerMessage"] = template.HTML(msg)
|
||||||
templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r)
|
templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r)
|
||||||
honkpage(w, u, honks, templinfo)
|
honkpage(w, u, honks, templinfo)
|
||||||
|
@ -591,7 +592,7 @@ func showcombo(w http.ResponseWriter, r *http.Request) {
|
||||||
honks = osmosis(honks, u.UserID)
|
honks = osmosis(honks, u.UserID)
|
||||||
templinfo := getInfo(r)
|
templinfo := getInfo(r)
|
||||||
templinfo["PageName"] = "combo"
|
templinfo["PageName"] = "combo"
|
||||||
templinfo["PageArg"] = "name"
|
templinfo["PageArg"] = name
|
||||||
templinfo["ServerMessage"] = "honks by combo: " + name
|
templinfo["ServerMessage"] = "honks by combo: " + name
|
||||||
templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r)
|
templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r)
|
||||||
honkpage(w, u, honks, templinfo)
|
honkpage(w, u, honks, templinfo)
|
||||||
|
@ -601,6 +602,12 @@ func showconvoy(w http.ResponseWriter, r *http.Request) {
|
||||||
u := login.GetUserInfo(r)
|
u := login.GetUserInfo(r)
|
||||||
honks := gethonksbyconvoy(u.UserID, c)
|
honks := gethonksbyconvoy(u.UserID, c)
|
||||||
templinfo := getInfo(r)
|
templinfo := getInfo(r)
|
||||||
|
if len(honks) > 0 {
|
||||||
|
templinfo["TopXID"] = honks[0].XID
|
||||||
|
}
|
||||||
|
reversehonks(honks)
|
||||||
|
templinfo["PageName"] = "convoy"
|
||||||
|
templinfo["PageArg"] = c
|
||||||
templinfo["ServerMessage"] = "honks in convoy: " + c
|
templinfo["ServerMessage"] = "honks in convoy: " + c
|
||||||
templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r)
|
templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r)
|
||||||
honkpage(w, u, honks, templinfo)
|
honkpage(w, u, honks, templinfo)
|
||||||
|
@ -610,6 +617,8 @@ func showsearch(w http.ResponseWriter, r *http.Request) {
|
||||||
u := login.GetUserInfo(r)
|
u := login.GetUserInfo(r)
|
||||||
honks := gethonksbysearch(u.UserID, q)
|
honks := gethonksbysearch(u.UserID, q)
|
||||||
templinfo := getInfo(r)
|
templinfo := getInfo(r)
|
||||||
|
templinfo["PageName"] = "search"
|
||||||
|
templinfo["PageArg"] = q
|
||||||
templinfo["ServerMessage"] = "honks for search: " + q
|
templinfo["ServerMessage"] = "honks for search: " + q
|
||||||
templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r)
|
templinfo["HonkCSRF"] = login.GetCSRF("honkhonk", r)
|
||||||
honkpage(w, u, honks, templinfo)
|
honkpage(w, u, honks, templinfo)
|
||||||
|
@ -706,6 +715,7 @@ func showhonk(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
rawhonks := gethonksbyconvoy(honk.UserID, honk.Convoy)
|
rawhonks := gethonksbyconvoy(honk.UserID, honk.Convoy)
|
||||||
|
reversehonks(rawhonks)
|
||||||
var honks []*Honk
|
var honks []*Honk
|
||||||
for _, h := range rawhonks {
|
for _, h := range rawhonks {
|
||||||
if h.Public && (h.Whofore == 2 || h.IsAcked()) {
|
if h.Public && (h.Whofore == 2 || h.IsAcked()) {
|
||||||
|
@ -729,7 +739,8 @@ func honkpage(w http.ResponseWriter, u *login.UserInfo, honks []*Honk, templinfo
|
||||||
}
|
}
|
||||||
reverbolate(userid, honks)
|
reverbolate(userid, honks)
|
||||||
templinfo["Honks"] = honks
|
templinfo["Honks"] = honks
|
||||||
if len(honks) > 0 {
|
if templinfo["TopXID"] == nil && len(honks) > 0 {
|
||||||
|
log.Printf("setting topxid")
|
||||||
templinfo["TopXID"] = honks[0].XID
|
templinfo["TopXID"] = honks[0].XID
|
||||||
}
|
}
|
||||||
err := readviews.Execute(w, "honkpage.html", templinfo)
|
err := readviews.Execute(w, "honkpage.html", templinfo)
|
||||||
|
|
Loading…
Reference in New Issue