feat(go, ts): add system-region mapping and highlight functionality
This commit is contained in:
@@ -3,7 +3,6 @@ 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 pb from '@/lib/pocketbase';
|
||||
|
||||
interface SearchResult {
|
||||
system: string;
|
||||
@@ -11,26 +10,22 @@ interface SearchResult {
|
||||
}
|
||||
|
||||
async function loadAllSystems(): Promise<Array<SearchResult>> {
|
||||
// Fetch system names with regions from PocketBase, paginated and minimal fields
|
||||
const perPage = 1000;
|
||||
let page = 1;
|
||||
const out: Array<SearchResult> = [];
|
||||
const seen = new Set<string>();
|
||||
// loop pages until fewer than perPage items
|
||||
while (true) {
|
||||
const res = await pb.collection('regionview').getList(page, perPage, { fields: 'sysname,sysregion' });
|
||||
for (const item of res.items as any[]) {
|
||||
const system: string = item.sysname;
|
||||
const region: string = item.sysregion;
|
||||
if (!seen.has(system)) {
|
||||
// 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<string>();
|
||||
const out: Array<SearchResult> = [];
|
||||
for (const item of list) {
|
||||
const system = String(item.system);
|
||||
if (seen.has(system)) continue;
|
||||
seen.add(system);
|
||||
out.push({ system, region });
|
||||
out.push({ system, region: String(item.region) });
|
||||
}
|
||||
return out;
|
||||
}
|
||||
if (res.items.length < perPage) break;
|
||||
page += 1;
|
||||
}
|
||||
return out;
|
||||
} catch (_) { /* noop */ }
|
||||
return [];
|
||||
}
|
||||
|
||||
export const SearchDialog: React.FC = () => {
|
||||
|
||||
Reference in New Issue
Block a user