Add sun/moon emojis to sunrise/sunset and fix direction sorting (direction 1 always on top)

This commit is contained in:
2025-12-31 18:50:33 +01:00
parent 8ff9b43247
commit d15142f1c6
4 changed files with 47 additions and 23 deletions

View File

@@ -420,12 +420,21 @@ function groupDeparturesByLineNumber(departures) {
groups[lineNumber].directions[directionKey].departures.push(departure);
});
// Convert to array format
// Convert to array format and sort directions by direction_code (1 first, then 2)
return Object.entries(groups).map(([lineNumber, data]) => {
// Sort directions: direction 1 first, then direction 2
const directionsArray = Object.values(data.directions);
directionsArray.sort((a, b) => {
// Sort by direction_code: 1 comes before 2
const dirA = a.direction || 1;
const dirB = b.direction || 1;
return dirA - dirB;
});
return {
lineNumber: lineNumber,
line: data.line,
directions: Object.values(data.directions)
directions: directionsArray
};
});
}