[ui] also add pre-label to result of search getObjects

feat/vaults
Tomáš Mládek 2022-01-27 21:26:47 +01:00
parent ad21ed6857
commit 6b5b8f4bb9
No known key found for this signature in database
GPG Key ID: ED21612889E75EC5
2 changed files with 11 additions and 6 deletions

View File

@ -6,15 +6,20 @@ export function baseSearch(query: string) {
return queryFn(() => `(matches ? ? (contains "${query}"))`); return queryFn(() => `(matches ? ? (contains "${query}"))`);
} }
export async function getObjects(entries: UpEntry[]): Promise<string[]> { export async function getObjects(
entries: UpEntry[]
): Promise<[string, string][]> {
const labelled = entries const labelled = entries
.filter((e) => e.attribute == "LBL") .filter((e) => e.attribute == "LBL")
.map((e) => e.entity); .map((e) => [e.entity, String(e.value.c)] as [string, string]);
const aliased = entries const aliased = entries
.filter((e) => e.attribute === "ALIAS") .filter((e) => e.attribute === "ALIAS")
.map(async (e) => { .map(async (aliasEntry) => {
const entry = await fetchEntry(e.entity); const entry = await fetchEntry(aliasEntry.entity);
return String(entry.value.c); return [String(entry.value.c), String(aliasEntry.value.c)] as [
string,
string
];
}); });
return labelled.concat(await Promise.all(aliased)); return labelled.concat(await Promise.all(aliased));
} }

View File

@ -70,7 +70,7 @@
{#if objects.length} {#if objects.length}
<h2>Objects</h2> <h2>Objects</h2>
<ul> <ul>
{#each objects as address} {#each objects as [address, _]}
<li> <li>
<UpObjectDisplay <UpObjectDisplay
{address} {address}