Skip to content

Commit

Permalink
🪲 Fix site crash when scenario was deleted from DB.
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasGilg committed Jan 30, 2024
1 parent b1befd5 commit 8cdae85
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions frontend/docs/changelog/changelog-de.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
- Ein Fehler wurde behoben, der beim ersten Laden der Seite den Text in der Suchleiste nicht übersetzt hatte.
- Ein Fehler wurde behoben, der Landkreise mit fehlenden Daten verschwinden lies.
- Ein Fehler wurde behoben, der die Webseite abstürzen lässt, nachdem die zugrunde liegenden Daten aktualisiert wurden.
- Ein Fehler wurde behoben, der die Webseite abstürzen lässt, wenn ein Szenario aus der Datenbank entfernt wurde.

---

Expand Down
1 change: 1 addition & 0 deletions frontend/docs/changelog/changelog-en.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
- An error was fixed, which prevented the text in the search bar to be translated on an initial site visit.
- Fixed an error, where districts with missing values weren't shown.
- Fixed an error, which crashed the website when the data was updated.
- Fixed an error, which crashed the website when a scenario was removed from the database.

---

Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/SimulationChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export default function SimulationChart(): JSX.Element {
const {data: simulationData, isFetching: simulationFetching} = useGetMultipleSimulationDataByNodeQuery(
{
// Filter only scenarios (scenario id 0 is case data)
ids: activeScenarios ? activeScenarios.filter((s) => s !== 0) : [],
ids: activeScenarios ? activeScenarios.filter((s) => s !== 0 && scenarioList.scenarios[s]) : [],
node: selectedDistrict,
groups: ['total'],
compartments: [selectedCompartment ?? ''],
Expand Down Expand Up @@ -689,7 +689,7 @@ export default function SimulationChart(): JSX.Element {
if (activeScenarios) {
activeScenarios.forEach((scenarioId) => {
// Skip case data (already added)
if (scenarioId === 0) {
if (scenarioId === 0 || !scenarioList.scenarios[scenarioId]) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {groupApi} from './services/groupApi';
const persistConfig = {
key: 'root',
storage,
whitelist: ['dataSelection', 'userPreference', 'scenarioList'],
whitelist: ['dataSelection', 'userPreference'],
};

const rootReducer = combineReducers({
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/store/services/scenarioApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const scenarioApi = createApi({
getSimulations: builder.query<Simulations, void>({
query: () => {
return `simulations/`;
},
}
}),

getSimulationDataByDate: builder.query<SimulationDataByDate, SimulationDataByDateParameters>({
Expand Down

0 comments on commit 8cdae85

Please sign in to comment.