feat: allow filtering with null (no) rating

This commit is contained in:
2023-08-20 20:13:47 +02:00
parent aeb067aadb
commit 93f359e684
12 changed files with 67 additions and 36 deletions

View File

@ -18,11 +18,7 @@ export async function fetchQueryResource(url: URL, type = "") {
try {
url.pathname = "/api/resources";
if (query) {
url.searchParams.set("q", encodeURIComponent(query));
} else {
return;
}
url.searchParams.set("q", encodeURIComponent(query || "*"));
if (status) {
url.searchParams.set("status", "not-seen");
}
@ -45,7 +41,7 @@ export const RedirectSearchHandler = () => {
e.key === "?" &&
window.location.search === ""
) {
window.location.href += "?q=";
window.location.href += "?q=*";
}
}, IS_BROWSER ? document?.body : undefined);
}
@ -127,9 +123,9 @@ const Search = (
u.searchParams.set("q", searchQuery.value);
}
if (showSeenStatus.value) {
u.searchParams.set("status", "not-seen");
u.searchParams.set("rating", "0");
} else {
u.searchParams.delete("status");
u.searchParams.delete("rating");
}
window.history.replaceState({}, "", u);
@ -191,7 +187,7 @@ const Search = (
onInput={handleInputChange}
/>
</div>
<Checkbox label="seen" checked={showSeenStatus} />
<Checkbox label="not-seen" checked={showSeenStatus} />
<Rating rating={4} />
</header>
{data?.value?.hits?.length && !isLoading.value