Skip to content

Commit

Permalink
πŸ› [eb/sbf] do not crash when vehicle or building is of unknown type
Browse files Browse the repository at this point in the history
(cherry picked from commit 86dd9fb)
  • Loading branch information
jxn-30 committed Nov 22, 2023
1 parent e8fceb3 commit c70e976
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/modules/extendedBuilding/assets/schoolsBuildingFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,29 +60,33 @@ export default async (LSSM: Vue) => {
const vehicleAllOption = document.createElement('option');
vehicleAllOption.value = '*';
vehicleTypeFilter.append(vehicleAllOption);
const vehicleTypeCaption = (vehicleType: number) =>
vehicleTypes[vehicleType]?.caption ?? `πŸ¦„ [${vehicleType}]`;
Array.from(new Set(buildings.flatMap(({ vehicleTypes }) => vehicleTypes)))
.sort((a, b) =>
vehicleTypes[a].caption.localeCompare(vehicleTypes[b].caption)
vehicleTypeCaption(a).localeCompare(vehicleTypeCaption(b))
)
.forEach(vehicleType => {
const option = document.createElement('option');
option.value = vehicleType.toString();
option.textContent = vehicleTypes[vehicleType].caption;
option.textContent = vehicleTypeCaption(vehicleType);
vehicleTypeFilter.append(option);
});

const buildingTypeFilter = document.createElement('select');
const buildingAllOption = document.createElement('option');
buildingAllOption.value = '*';
buildingTypeFilter.append(buildingAllOption);
const buildingTypeCaption = (buildingType: number) =>
buildingTypes[buildingType]?.caption ?? `🌈 [${buildingType}]`;
Array.from(new Set(buildings.map(({ buildingType }) => buildingType)))
.sort((a, b) =>
buildingTypes[a].caption.localeCompare(buildingTypes[b].caption)
buildingTypeCaption(a).localeCompare(buildingTypeCaption(b))
)
.forEach(buildingType => {
const option = document.createElement('option');
option.value = buildingType.toString();
option.textContent = buildingTypes[buildingType].caption;
option.textContent = buildingTypeCaption(buildingType);
buildingTypeFilter.append(option);
});

Expand Down

0 comments on commit c70e976

Please sign in to comment.