Skip to content

Commit

Permalink
front: fix initialization of a PaginatedContributorRatingList
Browse files Browse the repository at this point in the history
  • Loading branch information
GresilleSiffle committed Dec 19, 2024
1 parent b384266 commit daf9560
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions frontend/src/pages/videos/VideoRatings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,17 @@ const NoRatingMessage = ({ hasFilter }: { hasFilter: boolean }) => {

const VideoRatingsPage = () => {
const { name: pollName, options } = useCurrentPoll();
const [ratings, setRatings] = useState<PaginatedContributorRatingList>({});
const [ratings, setRatings] = useState<PaginatedContributorRatingList>({
count: 0,
results: [],
});
const [isLoading, setIsLoading] = useState(true);
const location = useLocation();
const history = useHistory();
const { t } = useTranslation();
const searchParams = new URLSearchParams(location.search);
const limit = 20;
const offset = Number(searchParams.get('offset') || 0);
const videoCount = ratings.count || 0;
const hasFilter = searchParams.get('isPublic') != null;

const handleOffsetChange = (newOffset: number) => {
Expand Down Expand Up @@ -119,10 +121,10 @@ const VideoRatingsPage = () => {
displayContextAlert={true}
/>
</LoaderWrapper>
{!isLoading && videoCount > 0 && videoCount > limit && (
{!isLoading && ratings.count > 0 && ratings.count > limit && (
<Pagination
offset={offset}
count={videoCount}
count={ratings.count}
onOffsetChange={handleOffsetChange}
limit={limit}
/>
Expand Down

0 comments on commit daf9560

Please sign in to comment.