fix: search store now parses API envelope response correctly

The search API returns { success, data: [...] } but the store was
looking for data.apps and data.boards (which don't exist). Fixed to
read from data.data[] and also added url/icon fields to search API
response so app results are clickable and show icons.
This commit is contained in:
2026-03-25 21:12:17 +03:00
parent 92eeeadec0
commit bcde710cab
2 changed files with 32 additions and 32 deletions
+15 -18
View File
@@ -100,31 +100,28 @@ class SearchStore {
return;
}
const data = await res.json();
const json = await res.json();
const results = json.data ?? [];
const items: SearchResultItem[] = [];
if (data.apps) {
for (const app of data.apps) {
for (const item of results) {
if (item.type === 'app') {
items.push({
type: 'app',
id: app.id,
name: app.name,
description: app.description ?? null,
url: app.url,
icon: app.icon ?? null
id: item.id,
name: item.name,
description: item.description ?? null,
url: item.url ?? `/apps/${item.id}`,
icon: item.icon ?? null
});
}
}
if (data.boards) {
for (const board of data.boards) {
} else if (item.type === 'board') {
items.push({
type: 'board',
id: board.id,
name: board.name,
description: board.description ?? null,
url: `/boards/${board.id}`,
icon: board.icon ?? null
id: item.id,
name: item.name,
description: item.description ?? null,
url: `/boards/${item.id}`,
icon: item.icon ?? null
});
}
}