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