fix: Refactor displayMetar to correctly load METAR by URL ID

Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
2026-02-14 18:13:06 -07:00
parent dc7345fb1d
commit c7a6fa4a11
+4 -4
View File
@@ -825,15 +825,15 @@
return;
}
let metarIndex = -1;
let metarIndex;
// If an ID is provided, try to find it.
if (id !== undefined) {
metarIndex = metars.findIndex(m => m.line === id);
}
if (metarIndex === -1) {
// Bias random selection towards the more interesting (higher-scored) METARs.
// Math.random() * Math.random() skews distribution towards 0.
// If no ID was provided, or the ID was not found, pick a random METAR.
if (id === undefined || metarIndex === -1) {
const randomSortedIndex = Math.floor(Math.random() * Math.random() * sortedMetars.length);
const selectedMetar = sortedMetars[randomSortedIndex];
metarIndex = metars.findIndex(m => m.metar === selectedMetar.metar);