mirror of
https://codeberg.org/video-prize-ranch/rimgo.git
synced 2025-07-17 16:48:24 +00:00
remove user comment pagination
?
This commit is contained in:
parent
8bb1ab0810
commit
b8329145f1
@ -102,8 +102,8 @@ func (client *Client) FetchSubmissions(username string, sort string, page string
|
||||
return submissions, nil
|
||||
}
|
||||
|
||||
func (client *Client) FetchUserComments(username string, page string) ([]Comment, error) {
|
||||
cacheData, found := client.Cache.Get(username + "-usercomments-" + page)
|
||||
func (client *Client) FetchUserComments(username string) ([]Comment, error) {
|
||||
cacheData, found := client.Cache.Get(username + "-usercomments")
|
||||
if found {
|
||||
return cacheData.([]Comment), nil
|
||||
}
|
||||
@ -150,7 +150,7 @@ func (client *Client) FetchUserComments(username string, page string) ([]Comment
|
||||
)
|
||||
wg.Wait()
|
||||
|
||||
client.Cache.Set(username+"-usercomments-"+page, comments, cache.DefaultExpiration)
|
||||
client.Cache.Set(username+"-usercomments", comments, cache.DefaultExpiration)
|
||||
return comments, nil
|
||||
}
|
||||
|
||||
|
@ -62,16 +62,6 @@ func HandleUserComments(c *fiber.Ctx) error {
|
||||
c.Set("Cache-Control", "public,max-age=604800")
|
||||
c.Set("Content-Security-Policy", "default-src 'none'; frame-ancestors 'none'; base-uri 'none'; form-action 'self'; media-src 'self'; style-src 'unsafe-inline' 'self'; img-src 'self'; manifest-src 'self'; block-all-mixed-content")
|
||||
|
||||
page := "0"
|
||||
if c.Query("page") != "" {
|
||||
page = c.Query("page")
|
||||
}
|
||||
|
||||
pageNumber, err := strconv.Atoi(c.Query("page"))
|
||||
if err != nil {
|
||||
pageNumber = 0
|
||||
}
|
||||
|
||||
user, err := ApiClient.FetchUser(c.Params("userID"))
|
||||
if err != nil && err.Error() == "ratelimited by imgur" {
|
||||
return c.Status(429).Render("errors/429", fiber.Map{
|
||||
@ -85,7 +75,7 @@ func HandleUserComments(c *fiber.Ctx) error {
|
||||
return c.Status(404).Render("errors/404", nil)
|
||||
}
|
||||
|
||||
comments, err := ApiClient.FetchUserComments(c.Params("userID"), page)
|
||||
comments, err := ApiClient.FetchUserComments(c.Params("userID"))
|
||||
if err != nil && err.Error() == "ratelimited by imgur" {
|
||||
c.Status(429)
|
||||
return c.Render("errors/429", fiber.Map{
|
||||
@ -99,8 +89,5 @@ func HandleUserComments(c *fiber.Ctx) error {
|
||||
return c.Render("userComments", fiber.Map{
|
||||
"user": user,
|
||||
"comments": comments,
|
||||
"page": page,
|
||||
"nextPage": pageNumber + 1,
|
||||
"prevPage": pageNumber - 1,
|
||||
})
|
||||
}
|
||||
|
@ -36,14 +36,6 @@
|
||||
{{> partials/contextComment }}
|
||||
{{/each}}
|
||||
</div>
|
||||
|
||||
<div class="mt-4 font-bold">
|
||||
{{#equal page "0" }}
|
||||
{{else}}
|
||||
<a href="{{channel.RelUrl}}?page={{prevPage}}">Previous page</a>
|
||||
{{/equal}}
|
||||
<a href="{{channel.RelUrl}}?page={{nextPage}}">Next page</a>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
{{> partials/footer }}
|
||||
|
Loading…
Reference in New Issue
Block a user