Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update default state to 'All' and filter valid states in browse logic #171

Merged
merged 1 commit into from
Nov 6, 2024
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
6 changes: 3 additions & 3 deletions src/lib/schema/browse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export const schema = z.object({
state: z
.array(
z.enum([
'',
'All',
'Unknown',
'Unreleased',
'Ongoing',
Expand All @@ -18,13 +18,13 @@ export const schema = z.object({
'Failed'
])
)
.default([]),
.default(['All']),
type: z.array(z.enum(['movie', 'show'])).default(['movie', 'show']),
sort: z.enum(['date_desc', 'date_asc', 'title_asc', 'title_desc']).default('date_desc')
});

export const states = {
'': 'Any State',
All: 'Any State',
Unknown: 'Unknown',
Unreleased: 'Unreleased',
Ongoing: 'Ongoing',
Expand Down
2 changes: 2 additions & 0 deletions src/routes/browse/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@
params
.get('state')
?.split(',')
.filter((state) => state in states)
.map((state) => state as keyof typeof states) || $formData.state;
$formData.type =
params
.get('type')
?.split(',')
.filter((type) => type in types)
.map((type) => type as keyof typeof types) || $formData.type;
$formData.sort = (params.get('sort') as keyof typeof sortOptions) || $formData.sort;
}
Expand Down
2 changes: 1 addition & 1 deletion src/routes/browse/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const load = (async ({ url }) => {
if (url.searchParams.has('state')) {
form.data.state = url.searchParams.get('state')?.split(',') as States[];
} else {
form.data.state = [''];
form.data.state = ['All'];
}

async function getItems(): Promise<RivenGetItemsResponse> {
Expand Down