Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/lib/components/market/page_size.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {query, state} from 'lit/decorators.js';
import {Get} from '../../bridge/handlers/storage_get';
import {Set} from '../../bridge/handlers/storage_set';
import {PAGE_SIZE} from '../../storage/keys';
import {hasQueryParameter} from '../../utils/browser';

@CustomElement()
export class PageSize extends FloatElement {
Expand Down Expand Up @@ -33,7 +34,11 @@ export class PageSize extends FloatElement {
super.connectedCallback();

const size = await Get(PAGE_SIZE);
if (size) {

// Don't override if the user is manually overriding the start query param
// ie. "https://steamcommunity.com/market/listings/730/AK-47%20%7C%20Slate%20%28Field-Tested%29?start=100&count=100"
// Steam already has a bug that pagination doesn't work when setting this.
if (size && !hasQueryParameter('start')) {
this.changePageSize(size);
}
}
Expand Down
12 changes: 12 additions & 0 deletions src/lib/utils/browser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Functions related to the browser page (ie. parsing the URL)
*/

export function getQueryParameter(param: string): string | null {
const url = new URL(window.location.href);
return url.searchParams.get(param);
}

export function hasQueryParameter(param: string): boolean {
return !!getQueryParameter(param);
}