Skip to content

Commit

Permalink
user overview sort
Browse files Browse the repository at this point in the history
  • Loading branch information
rystaf committed May 10, 2024
1 parent 80ca58a commit 944afd7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 11 additions & 0 deletions templates/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down

0 comments on commit 944afd7

Please sign in to comment.