From ef619cf0ef97c286be56ec2fc3e94ab1448fcbff Mon Sep 17 00:00:00 2001 From: Yader Velasquez Date: Fri, 9 Feb 2024 15:41:58 -0600 Subject: [PATCH] Fix short/list pagination to considere query param --- list/routes.go | 8 +++++--- short/routes.go | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/list/routes.go b/list/routes.go index cf02104..634d828 100644 --- a/list/routes.go +++ b/list/routes.go @@ -1006,8 +1006,10 @@ func (s *Service) ListingList(c echo.Context) error { op.Var("orgSlug", org.Slug) + var tag string if c.QueryParam("tag") != "" { - op.Var("tag", c.QueryParam("tag")) + tag = c.QueryParam("tag") + op.Var("tag", tag) } if c.QueryParam("next") != "" { @@ -1025,11 +1027,11 @@ func (s *Service) ListingList(c echo.Context) error { } gmap["lists"] = result.Listings.Result if result.Listings.PageInfo.HasPrevPage { - gmap["prevURL"] = links.GetPaginationParams("prev", "", "", result.Listings.PageInfo.Cursor) + gmap["prevURL"] = links.GetPaginationParams("prev", tag, "", result.Listings.PageInfo.Cursor) } if result.Listings.PageInfo.HasNextPage { - gmap["nextURL"] = links.GetPaginationParams("next", "", "", result.Listings.PageInfo.Cursor) + gmap["nextURL"] = links.GetPaginationParams("next", tag, "", result.Listings.PageInfo.Cursor) } return gctx.Render(http.StatusOK, "listing_list.html", gmap) } diff --git a/short/routes.go b/short/routes.go index 637426d..905db31 100644 --- a/short/routes.go +++ b/short/routes.go @@ -113,8 +113,10 @@ func (s *Service) LinkShortList(c echo.Context) error { op.Var("slug", slug) + var tag string if c.QueryParam("tag") != "" { - op.Var("tag", c.QueryParam("tag")) + tag = c.QueryParam("tag") + op.Var("tag", tag) } if c.QueryParam("next") != "" { @@ -154,11 +156,11 @@ func (s *Service) LinkShortList(c echo.Context) error { } if result.LinkShorts.PageInfo.HasPrevPage { - gmap["prevURL"] = links.GetPaginationParams("prev", "", "", result.LinkShorts.PageInfo.Cursor) + gmap["prevURL"] = links.GetPaginationParams("prev", tag, "", result.LinkShorts.PageInfo.Cursor) } if result.LinkShorts.PageInfo.HasNextPage { - gmap["nextURL"] = links.GetPaginationParams("next", "", "", result.LinkShorts.PageInfo.Cursor) + gmap["nextURL"] = links.GetPaginationParams("next", tag, "", result.LinkShorts.PageInfo.Cursor) } return gctx.Render(http.StatusOK, "link_short_list.html", gmap) } -- 2.45.2