From 944afd7d599fe9050bfdf0e7664f30416be853a2 Mon Sep 17 00:00:00 2001 From: Ryan Stafford Date: Thu, 9 May 2024 20:55:37 -0400 Subject: [PATCH] user overview sort --- routes.go | 5 +++++ state.go | 1 + templates/main.html | 11 +++++++++++ 3 files changed, 17 insertions(+) diff --git a/routes.go b/routes.go index 644c0ce..875f814 100644 --- a/routes.go +++ b/routes.go @@ -638,6 +638,11 @@ func GetComment(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { } func GetUser(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { state, err := Initialize(ps.ByName("host"), r) + state.Sort = "New" + m, _ := url.ParseQuery(r.URL.RawQuery) + if len(m["sort"]) > 0 { + state.Sort = m["sort"][0] + } if err != nil { Render(w, "index.html", state) return diff --git a/state.go b/state.go index d828a22..3d86931 100644 --- a/state.go +++ b/state.go @@ -491,6 +491,7 @@ func (state *State) GetUser(username string) { Page: lemmy.NewOptional(int64(state.Page)), Limit: lemmy.NewOptional(int64(limit)), SavedOnly: lemmy.NewOptional(state.Op == "Saved"), + Sort: lemmy.NewOptional(lemmy.SortType(state.Sort)), }) if err != nil { fmt.Println(err) diff --git a/templates/main.html b/templates/main.html index eadb11f..cc87ce0 100644 --- a/templates/main.html +++ b/templates/main.html @@ -99,6 +99,17 @@ {{ end }} {{ end }} {{ end}} + {{ if and .User .Activities }} +
+
+ sorted by: + new + top + controversial + old +
+
+ {{ end }} {{ range $i, $comment := .Comments }}