mirror of
https://github.com/jamescliffordspratt/macros.git
synced 2026-07-22 05:46:53 +00:00
Fix micronutrient dropdown toggle and resilient All-tab search (allSettled)
This commit is contained in:
parent
c93c488451
commit
4f414251d6
3 changed files with 9 additions and 4 deletions
|
|
@ -332,8 +332,13 @@ export async function searchAllSources(
|
|||
);
|
||||
}
|
||||
|
||||
// Execute searches in parallel
|
||||
const results = await Promise.all(searchPromises);
|
||||
// Execute searches in parallel. Use allSettled so that one failing source
|
||||
// (e.g. a network error or outage from a single API) doesn't wipe out the
|
||||
// results from the others.
|
||||
const settled = await Promise.allSettled(searchPromises);
|
||||
const results = settled
|
||||
.filter((r): r is PromiseFulfilledResult<UnifiedFoodResult[]> => r.status === 'fulfilled')
|
||||
.map((r) => r.value);
|
||||
|
||||
// Merge and deduplicate with enhanced prioritization
|
||||
const merged = mergeAndDedupeResults(...results);
|
||||
|
|
|
|||
|
|
@ -939,7 +939,7 @@ export class LiveFoodSearchModal extends Modal {
|
|||
}
|
||||
|
||||
escapeRegExp(string: string): string {
|
||||
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\');
|
||||
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -331,7 +331,7 @@ export class ManualFoodEntryModal extends Modal {
|
|||
let expanded = false;
|
||||
const toggle = () => {
|
||||
expanded = !expanded;
|
||||
body.style.display = expanded ? 'block' : 'none';
|
||||
body.toggleClass('macros-u-hidden', !expanded);
|
||||
toggleIcon.textContent = expanded ? '▼' : '▶';
|
||||
};
|
||||
this.component.registerDomEvent(header, 'click', toggle);
|
||||
|
|
|
|||
Loading…
Reference in a new issue