Skip to content

Commit 5e50a7a

Browse files
committed
chore: update to use per_page
Signed-off-by: Charlie Drage <[email protected]>
1 parent e0a0532 commit 5e50a7a

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/lib/ui/ExtensionsList.spec.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ test('check categories', async () => {
5050
expect(category2).toBeInTheDocument();
5151
});
5252

53-
test('if query is passed into window.location.search then it should be used to filter extensions', async () => {
53+
test('if per_page is passed into window.location.search then it should be used to filter extensions', async () => {
5454
// Mock query to be last 1
5555
vi.spyOn(window, 'location', 'get').mockReturnValue({
56-
search: '?query=1',
56+
search: '?per_page=1',
5757
} as unknown as Location);
5858

5959
const extensionsByCategories: ExtensionByCategoryInfo[] = [
@@ -108,10 +108,10 @@ test('if query is passed into window.location.search then it should be used to f
108108
expect(category2).not.toBeInTheDocument();
109109
});
110110

111-
test('if query is passed in with 4, it should show last 4 extensions even if there is 5 in the list', async () => {
111+
test('if per_page is passed in with 4, it should show last 4 extensions even if there is 5 in the list', async () => {
112112
// Mock query to be last 4
113113
vi.spyOn(window, 'location', 'get').mockReturnValue({
114-
search: '?query=4',
114+
search: '?per_page=4',
115115
} as unknown as Location);
116116

117117
const extensionsByCategories: ExtensionByCategoryInfo[] = [

src/lib/ui/ExtensionsList.svelte

+6-6
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ let { extensionsByCategories }: Props = $props();
1212
let filteredExtensions = $state<CatalogExtensionInfo[]>([]);
1313
let showCategories = $state<boolean>(true);
1414
15-
// Get the query from the URL
16-
function getQueryLimit(): number | undefined {
17-
const query = new URLSearchParams(window.location.search).get('query');
18-
return query ? parseInt(query, 10) : undefined;
15+
// Get the per_page from the URL
16+
function getPerPageLimit(): number | undefined {
17+
const perPage = new URLSearchParams(window.location.search).get('per_page');
18+
return perPage ? parseInt(perPage, 10) : undefined;
1919
}
2020
2121
// Sort extensions based upon the last updated date based upon what's in .versions array
@@ -28,7 +28,7 @@ function getSortedExtensions(extensions: CatalogExtensionInfo[]): CatalogExtensi
2828
}
2929
3030
$effect(() => {
31-
const limit = getQueryLimit();
31+
const limit = getPerPageLimit();
3232
showCategories = !limit;
3333
3434
if (limit) {
@@ -47,7 +47,7 @@ $effect(() => {
4747
<div
4848
class="mt-2 grid min-[920px]:grid-cols-2 min-[1180px]:grid-cols-3 gap-3"
4949
role="region"
50-
aria-label="Queried extensions"
50+
aria-label="Filtered extensions"
5151
>
5252
{#each filteredExtensions as extension}
5353
<ExtensionByCategoryCard {extension} />

0 commit comments

Comments
 (0)