Skip to content

[2.x] PostsUserPage passes loadLimit into the page constructor argument (dead code) #4790

Description

@karl-bullock

Summary

PostsUserPage builds its PostListState with the intended per-request page size passed into the wrong constructor parameter, which makes the loadLimit field dead code. It is currently harmless, but the code is misleading and is a latent trap.

Details

framework/core/js/src/forum/components/PostsUserPage.tsx:

/** The number of activity items to load per request. */
loadLimit: number = 20;

oninit(...) {
  // ...
  this.posts = new PostListState({}, this.loadLimit);
}

PostListState's constructor signature (via PaginatedListState) is (params, page = 1, pageSize = null). So this.loadLimit (20) is passed as the page argument, not pageSize, even though the field is documented as the per-request item count.

Current behavior

It happens to be inert today, for two reasons:

  1. The constructor sets location = { page: 20 }, but show() immediately calls this.posts.refreshParams(this.params(user), 1) -> refresh(1) -> goto(1), which resets location to page 1 before any request is made. (location.page only feeds a request through getNextPageNumber() while no pages are loaded, and PostList's "load more" control is hidden until hasNext() is true, i.e. after a page has already loaded.)
  2. pageSize stays null and is then populated from the server's meta.perPage on load. Since PostResource::$defaultLimit = 20, the effective page size ends up as 20 anyway.

So loadLimit currently has no runtime effect: the profile feed paginates at the server default, not because of loadLimit.

Why it is worth noting

It is a latent trap: bumping loadLimit (e.g. to 50) to make the profile load larger pages would silently do nothing. The sibling DiscussionsUserPage has no loadLimit at all and simply relies on the server default, which is the consistent pattern.

Suggested fix

Either:

  • Remove the dead field and match DiscussionsUserPage: this.posts = new PostListState({});, or
  • Pass it in the correct position if a profile-specific size is actually wanted: new PostListState({}, 1, this.loadLimit);

Both are behavior-preserving today, since loadLimit (20) equals the server default.


Found while investigating the page[limit] handling in #4775 / #4773. Low severity, no user-visible impact. I'll look into it further before proposing a change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions