[ui] switch away from `query()` taking `() => string`
parent
a83149e746
commit
f35d614a83
|
@ -28,10 +28,9 @@
|
|||
$: allTypeAddresses = ($entity?.attr["IS"] || []).map((attr) => attr.value.c);
|
||||
|
||||
$: allTypeEntries = query(
|
||||
() =>
|
||||
`(matches (in ${allTypeAddresses
|
||||
.map((addr) => `"${addr}"`)
|
||||
.join(" ")}) ? ?)`
|
||||
`(matches (in ${allTypeAddresses
|
||||
.map((addr) => `"${addr}"`)
|
||||
.join(" ")}) ? ?)`
|
||||
).result;
|
||||
|
||||
let allTypes: { [key: string]: UpType } = {};
|
||||
|
|
|
@ -73,9 +73,7 @@
|
|||
|
||||
const addressesString = addresses.map((addr) => `"${addr}"`).join(" ");
|
||||
|
||||
labelListing = query(
|
||||
() => `(matches (in ${addressesString}) "LBL" ? )`
|
||||
).result;
|
||||
labelListing = query(`(matches (in ${addressesString}) "LBL" ? )`).result;
|
||||
}
|
||||
|
||||
// Sorting
|
||||
|
|
|
@ -34,12 +34,11 @@ export async function fetchEntry(address: string) {
|
|||
return listing.entries[0];
|
||||
}
|
||||
|
||||
export function query(query: () => string) {
|
||||
const queryString = typeof query === "string" ? query : query();
|
||||
console.debug(`Querying: ${queryString}`);
|
||||
export function query(query: string) {
|
||||
console.debug(`Querying: ${query}`);
|
||||
const { data, error, revalidate } = useSWR<ListingResult, unknown>(
|
||||
"/api/query",
|
||||
{ method: "POST", body: queryString }
|
||||
{ method: "POST", body: query }
|
||||
);
|
||||
|
||||
const result = derived(data, ($values) => {
|
||||
|
|
|
@ -4,8 +4,7 @@ import { query as queryFn, queryOnce } from "../lib/entity";
|
|||
|
||||
export function baseSearch(query: string) {
|
||||
return queryFn(
|
||||
() =>
|
||||
`(or (matches ? (contains "${query}") ?) (matches ? ? (contains "${query}")))`
|
||||
`(or (matches ? (contains "${query}") ?) (matches ? ? (contains "${query}")))`
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,9 +19,7 @@
|
|||
);
|
||||
})();
|
||||
|
||||
const { result: lastVisitedQuery } = query(
|
||||
() => `(matches ? "LAST_VISITED" ? )`
|
||||
);
|
||||
const { result: lastVisitedQuery } = query(`(matches ? "LAST_VISITED" ? )`);
|
||||
$: lastVisited = ($lastVisitedQuery?.entries || [])
|
||||
.filter((e) => e.value.t == "Number")
|
||||
.sort((a, b) => (b.value.c as number) - (a.value.c as number))
|
||||
|
|
Loading…
Reference in New Issue