mirror of
https://github.com/rystaf/mlmym.git
synced 2024-11-24 22:20:37 +00:00
inbox/profile: dont fetch comment replies when voting, show my votes, retain context link on vote. fixes #90
This commit is contained in:
parent
73c0e2aa83
commit
ed67986a0f
|
@ -1329,7 +1329,12 @@ func UserOp(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
|||
state.Client.LikeComment(context.Background(), post)
|
||||
if r.FormValue("xhr") != "" {
|
||||
state.XHR = true
|
||||
state.GetComment(commentid)
|
||||
if r.URL.Path == "/inbox" || r.URL.Path[:3] == "/u/" {
|
||||
state.Query = "show context link"
|
||||
state.GetSingleComment(commentid)
|
||||
} else {
|
||||
state.GetComment(commentid)
|
||||
}
|
||||
Render(w, "index.html", state)
|
||||
return
|
||||
}
|
||||
|
|
18
state.go
18
state.go
|
@ -298,6 +298,23 @@ func (state *State) GetSite() {
|
|||
})
|
||||
}
|
||||
|
||||
func (state *State) GetSingleComment(commentid int64) {
|
||||
state.CommentID = commentid
|
||||
cresp, err := state.Client.Comment(context.Background(), lemmy.GetComment{
|
||||
ID: commentid,
|
||||
})
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
state.Status = http.StatusInternalServerError
|
||||
return
|
||||
}
|
||||
state.Comments = []Comment{Comment{
|
||||
P: cresp.CommentView,
|
||||
State: state,
|
||||
Op: state.Op,
|
||||
}}
|
||||
}
|
||||
|
||||
func (state *State) GetComment(commentid int64) {
|
||||
if state.Sort != "Hot" && state.Sort != "Top" && state.Sort != "Old" && state.Sort != "New" {
|
||||
state.Sort = "Hot"
|
||||
|
@ -449,6 +466,7 @@ func (state *State) GetMessages() {
|
|||
Creator: m.Creator,
|
||||
Community: m.Community,
|
||||
Counts: m.Counts,
|
||||
MyVote: m.MyVote,
|
||||
},
|
||||
Op: unread,
|
||||
State: state,
|
||||
|
|
Loading…
Reference in a new issue