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:
+4
-4
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user