From 8264b63337e19e643f79190bfe93b7bd9a62acd4 Mon Sep 17 00:00:00 2001 From: kim Date: Tue, 6 May 2025 13:30:23 +0000 Subject: [bugfix] ensure timeline limit query is respected (#4141) # Description Fixes a bug in the new timeline code in which the limit query parameter wasn't always being fulfilled, in which case some clients like Tusky would then assume it didn't need to add a "load more" placeholder view even when there were more statuses to be loaded. This also fiddles around a bit in the logging middleware handler to add some more code comments, and add logging of full request URIs when it is safe to do so. ## Checklist - [x] I/we have read the [GoToSocial contribution guidelines](https://codeberg.org/superseriousbusiness/gotosocial/src/branch/main/CONTRIBUTING.md). - [x] I/we have discussed the proposed changes already, either in an issue on the repository, or in the Matrix chat. - [x] I/we have not leveraged AI to create the proposed changes. - [x] I/we have performed a self-review of added code. - [x] I/we have written code that is legible and maintainable by others. - [x] I/we have commented the added code, particularly in hard-to-understand areas. - [ ] I/we have made any necessary changes to documentation. - [x] I/we have added tests that cover new code. - [x] I/we have run tests and they pass locally with the changes. - [x] I/we have run `go fmt ./...` and `golangci-lint run`. Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4141 Co-authored-by: kim Co-committed-by: kim --- internal/paging/page.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'internal/paging/page.go') diff --git a/internal/paging/page.go b/internal/paging/page.go index 6c91da6b2..708ab1bd7 100644 --- a/internal/paging/page.go +++ b/internal/paging/page.go @@ -278,10 +278,10 @@ func (p *Page) ToLinkURL(proto, host, path string, queryParams url.Values) *url. if queryParams == nil { // Allocate new query parameters. - queryParams = make(url.Values) + queryParams = make(url.Values, 2) } else { // Before edit clone existing params. - queryParams = cloneQuery(queryParams) + queryParams = cloneQuery(queryParams, 2) } if p.Min.Value != "" { @@ -309,8 +309,8 @@ func (p *Page) ToLinkURL(proto, host, path string, queryParams url.Values) *url. } // cloneQuery clones input map of url values. -func cloneQuery(src url.Values) url.Values { - dst := make(url.Values, len(src)) +func cloneQuery(src url.Values, extra int) url.Values { + dst := make(url.Values, len(src)+extra) for k, vs := range src { dst[k] = slices.Clone(vs) } -- cgit v1.2.3