generated from it-at-m/oss-repository-en-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
wls-gui-wahllokalsystemfrontend related issues for Wahllokalsystemfrontend related issues for Wahllokalsystem
Description
⚠️ Potential issue | 🔴 CriticalFix potential false 404: wait until wahlen are loaded before redirecting.
The watcher triggers on wahlID; if wahlen aren’t initialized yet, wahl is undefined and you redirect erroneously.
Apply:
-import { storeToRefs } from "pinia"; -import { computed, watch } from "vue"; +import { storeToRefs } from "pinia"; +import { computed, watchEffect } from "vue"; ... -const { wahlenActions } = useWahlenStore(); +const wahlenStore = useWahlenStore(); +const { wahlenActions } = wahlenStore; +const { wahlenState } = storeToRefs(wahlenStore); ... -watch( - () => wahlID.value, - () => { - if (!wahl.value) { - router.push({ name: EXAMPLE_ROUTES_NOTFOUND }); - } - } -); +watchEffect(() => { + // redirect only after wahlen finished loading (null -> loaded array) + if (wahlenState.value.wahlen !== null && !wahl.value) { + router.push({ name: EXAMPLE_ROUTES_NOTFOUND }); + } +});Also applies to: 15-15, 24-25, 27-33, 37-44
🤖 Prompt for AI Agents
In wls-gui-wahllokalsystem/src/views/auszaehlung/ErfassungStimmzettelView.vue around lines 3, 15, 24-25, 27-33 and 37-44, the watcher and redirects run as soon as wahlID changes even if the wahlen list hasn't finished loading, causing false 404 redirects when wahl is undefined; update each watcher and any redirect logic to first wait for wahlen to be initialized (e.g., check a loaded flag or that wahlen.length > 0) before attempting to look up the wahl by ID and redirect, and guard all uses of getStimmzettelTermForWahl(wahl) and similar calls with a null/undefined check so you only compute the title or redirect when the matching wahl is present.
Originally posted by @coderabbitai[bot] in #2047 (comment)
Metadata
Metadata
Assignees
Labels
wls-gui-wahllokalsystemfrontend related issues for Wahllokalsystemfrontend related issues for Wahllokalsystem