Skip to content

Commit

Permalink
refactor: Better checks for libv2 data loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
yusuf-musleh committed Jul 5, 2024
1 parent 3292376 commit 05eda0a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/studio-home/tabs-section/libraries-v2-tab/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const LibrariesV2Tab = ({
: `${window.location.origin}${getPath(getConfig().PUBLIC_PATH)}library/${id}`
);

const hasV2Libraries = (data?.results?.length || 0) > 0;
const hasV2Libraries = !isLoading && ((data!.results.length || 0) > 0);

return (
isError ? (
Expand Down Expand Up @@ -90,15 +90,15 @@ const LibrariesV2Tab = ({
&& (
<p data-testid="pagination-info">
{intl.formatMessage(messages.coursesPaginationInfo, {
length: data.results.length,
total: data.count,
length: data!.results.length,
total: data!.count,
})}
</p>
)}
</div>

{ hasV2Libraries
? data?.results.map(({
? data!.results.map(({
id, org, slug, title,
}) => (
<CardItem
Expand All @@ -124,12 +124,12 @@ const LibrariesV2Tab = ({
)}

{
(data?.numPages || 0) > 1
hasV2Libraries && (data!.numPages || 0) > 1
&& (
<Pagination
className="d-flex justify-content-center"
paginationLabel="pagination navigation"
pageCount={data?.numPages}
pageCount={data!.numPages}
currentPage={currentPage}
onPageSelect={handlePageSelect}
/>
Expand Down

0 comments on commit 05eda0a

Please sign in to comment.