hide all toggle, get comments/posts bugfixes

This commit is contained in:
Ryan Stafford 2023-07-05 16:59:23 -04:00
parent 834d8170d1
commit ae0c8427d2
2 changed files with 20 additions and 7 deletions

View file

@ -104,9 +104,11 @@ function hideAllChildComments(e) {
if (children.className.indexOf("hidden") == -1) {
children.className = "children hidden"
btn.className = "hidechildren hidden"
e.target.innerHTML = "show all child comments"
} else {
children.className = "children"
btn.className = "hidechildren"
e.target.innerHTML = "hide all child comments"
}
}
return false

View file

@ -269,6 +269,14 @@ func (state *State) GetComments() {
Limit: types.NewOptional(int64(200)),
Page: types.NewOptional(int64(state.Page)),
})
if err != nil && strings.Contains(fmt.Sprintf("%v", err), "couldnt_get_comments") {
cresp, err = state.Client.Comments(context.Background(), types.GetComments{
PostID: types.NewOptional(state.PostID),
Sort: types.NewOptional(types.CommentSortType(state.Sort)),
Type: types.NewOptional(types.ListingType("All")),
Page: types.NewOptional(int64(state.Page)),
})
}
if err != nil {
state.Status = http.StatusInternalServerError
fmt.Println(err)
@ -432,13 +440,16 @@ func (state *State) MarkAllAsRead() {
}
func (state *State) GetPosts() {
resp, err := state.Client.Posts(context.Background(), types.GetPosts{
posts := types.GetPosts{
Sort: types.NewOptional(types.SortType(state.Sort)),
Type: types.NewOptional(types.ListingType(state.Listing)),
CommunityName: types.NewOptional(state.CommunityName),
Limit: types.NewOptional(int64(25)),
Page: types.NewOptional(int64(state.Page)),
})
}
if state.CommunityName != "" {
posts.CommunityName = types.NewOptional(state.CommunityName)
}
resp, err := state.Client.Posts(context.Background(), posts)
if err != nil {
fmt.Println(err)
state.Status = http.StatusInternalServerError