user overview sort

This commit is contained in:
Ryan Stafford 2024-05-09 20:55:37 -04:00
parent 80ca58a55f
commit 944afd7d59
3 changed files with 17 additions and 0 deletions

View file

@ -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

View file

@ -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)

View file

@ -99,6 +99,17 @@
{{ end }}
{{ end }}
{{ end}}
{{ if and .User .Activities }}
<div id="comments" class="commentmenu">
<div>
sorted by:
<a {{ if eq .Sort "New"}}class="selected"{{end}} href="{{ .SortBy "New"}}">new</a>
<a {{ if eq .Sort "TopAll"}}class="selected"{{end}} href="{{ .SortBy "TopAll"}}">top</a>
<a {{ if eq .Sort "Controversial"}}class="selected"{{end}} href="{{ .SortBy "Controversial"}}">controversial</a>
<a {{ if eq .Sort "Old"}}class="selected"{{end}} href="{{ .SortBy "Old"}}">old</a>
</div>
</div>
{{ end }}
{{ range $i, $comment := .Comments }}