Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
DavideIadeluca committed Oct 27, 2024
1 parent fe74ddb commit 3b80c36
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions js/src/forum/components/VotesUserPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import app from 'flarum/forum/app';
import PostsUserPage from 'flarum/forum/components/PostsUserPage';

import type Post from 'flarum/common/models/Post';
import type { ApiQueryParamsPlural } from 'flarum/common/Store';

/**
* The `VotesUserPage` component shows posts which user voted on.
*/
Expand All @@ -12,14 +14,16 @@ export default class VotesUserPage extends PostsUserPage {
* @param offset The position to start getting results from.
* @protected
*/
loadResults(offset: number) {
return app.store.find<Post[]>('posts', {
loadResults(offset: number = 0) {
const params: ApiQueryParamsPlural = {
filter: {
type: 'comment',
voted: this.user.id(),
...(this.user?.id() && { voted: this.user.id() }),
},
page: { offset, limit: this.loadLimit },
sort: '-createdAt',
});
};

return app.store.find<Post[]>('posts', params);
}
}

0 comments on commit 3b80c36

Please sign in to comment.