From 3b80c3621328070acb6cfc6ab9c6c22377382f63 Mon Sep 17 00:00:00 2001 From: Davide Iadeluca Date: Sun, 27 Oct 2024 11:24:44 +0100 Subject: [PATCH] refactor --- js/src/forum/components/VotesUserPage.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/js/src/forum/components/VotesUserPage.ts b/js/src/forum/components/VotesUserPage.ts index e731c74..b27b0cc 100644 --- a/js/src/forum/components/VotesUserPage.ts +++ b/js/src/forum/components/VotesUserPage.ts @@ -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. */ @@ -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('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('posts', params); } }