mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-20 05:56:53 +00:00
fix(maps): read the index terms when a row is judged, not when the module loads (PLN-02)
A suite that stubs the places index client without its term table could no longer load the maps service, because the list of every term was built when the module was first imported. It is read where a row is judged now.
This commit is contained in:
@@ -151,9 +151,6 @@ export function indexRequestsPerKind(plan: IndexPoiPlan): IndexRequest[] {
|
||||
);
|
||||
}
|
||||
|
||||
/** Every term the index is asked by, whichever kind asks for it. */
|
||||
const EVERY_TERM = Object.values(POI_CATEGORY_TO_TREK).flat();
|
||||
|
||||
/**
|
||||
* Whether a row's most specific known term is one an asked kind asks for. A
|
||||
* water park lies under the parks' path, but `activity` names its own path for
|
||||
@@ -165,7 +162,9 @@ export function ownedByAsked(
|
||||
row: { category: string | null; categoryPath: string | null },
|
||||
asked: readonly string[],
|
||||
): boolean {
|
||||
const term = indexRowTerm(EVERY_TERM, row.category, row.categoryPath);
|
||||
// Every term the index is asked by, whichever kind asks for it; read here, not
|
||||
// when the module loads, so a suite that stubs the index client stays loadable.
|
||||
const term = indexRowTerm(Object.values(POI_CATEGORY_TO_TREK).flat(), row.category, row.categoryPath);
|
||||
return term === undefined || asked.some((kind) => POI_CATEGORY_TO_TREK[kind]?.includes(term));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user