From 7af7d9ecd023eac8d184a3388321bbe72d0879f1 Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Sun, 10 Aug 2025 22:26:54 +0200 Subject: [PATCH] refactor(SearchDialog.tsx): simplify system loading by directly calling ListSystemsWithRegions --- frontend/src/components/SearchDialog.tsx | 27 ++++++++++-------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/frontend/src/components/SearchDialog.tsx b/frontend/src/components/SearchDialog.tsx index 5a51e75..41a82a3 100644 --- a/frontend/src/components/SearchDialog.tsx +++ b/frontend/src/components/SearchDialog.tsx @@ -3,6 +3,7 @@ import { useNavigate } from 'react-router-dom'; import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog'; import { Input } from '@/components/ui/input'; import { AhoCorasick } from '@/lib/aho'; +import { ListSystemsWithRegions } from 'wailsjs/go/main/App'; interface SearchResult { system: string; @@ -10,22 +11,16 @@ interface SearchResult { } async function loadAllSystems(): Promise> { - // Fetch from Go (Wails): local SQLite DB via App.ListSystemsWithRegions - try { - const list = await (window as any)?.go?.main?.App?.ListSystemsWithRegions?.(); - if (Array.isArray(list)) { - const seen = new Set(); - const out: Array = []; - for (const item of list) { - const system = String(item.system); - if (seen.has(system)) continue; - seen.add(system); - out.push({ system, region: String(item.region) }); - } - return out; - } - } catch (_) { /* noop */ } - return []; + const list = await ListSystemsWithRegions(); + const seen = new Set(); + const out: Array = []; + for (const item of list) { + const system = String(item.system); + if (seen.has(system)) continue; + seen.add(system); + out.push({ system, region: String(item.region) }); + } + return out; } export const SearchDialog: React.FC = () => {