refactor(SearchDialog.tsx): simplify system loading by directly calling ListSystemsWithRegions
This commit is contained in:
@@ -3,6 +3,7 @@ import { useNavigate } from 'react-router-dom';
|
|||||||
import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog';
|
import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog';
|
||||||
import { Input } from '@/components/ui/input';
|
import { Input } from '@/components/ui/input';
|
||||||
import { AhoCorasick } from '@/lib/aho';
|
import { AhoCorasick } from '@/lib/aho';
|
||||||
|
import { ListSystemsWithRegions } from 'wailsjs/go/main/App';
|
||||||
|
|
||||||
interface SearchResult {
|
interface SearchResult {
|
||||||
system: string;
|
system: string;
|
||||||
@@ -10,10 +11,7 @@ interface SearchResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function loadAllSystems(): Promise<Array<SearchResult>> {
|
async function loadAllSystems(): Promise<Array<SearchResult>> {
|
||||||
// Fetch from Go (Wails): local SQLite DB via App.ListSystemsWithRegions
|
const list = await ListSystemsWithRegions();
|
||||||
try {
|
|
||||||
const list = await (window as any)?.go?.main?.App?.ListSystemsWithRegions?.();
|
|
||||||
if (Array.isArray(list)) {
|
|
||||||
const seen = new Set<string>();
|
const seen = new Set<string>();
|
||||||
const out: Array<SearchResult> = [];
|
const out: Array<SearchResult> = [];
|
||||||
for (const item of list) {
|
for (const item of list) {
|
||||||
@@ -23,9 +21,6 @@ async function loadAllSystems(): Promise<Array<SearchResult>> {
|
|||||||
out.push({ system, region: String(item.region) });
|
out.push({ system, region: String(item.region) });
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
|
||||||
} catch (_) { /* noop */ }
|
|
||||||
return [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const SearchDialog: React.FC = () => {
|
export const SearchDialog: React.FC = () => {
|
||||||
|
Reference in New Issue
Block a user