From 3cdc64674b3539d901ac9f2e594fb54737f88dae Mon Sep 17 00:00:00 2001 From: Julian Krauser Date: Thu, 5 Sep 2024 16:25:25 +0200 Subject: [PATCH] store reset fix --- src/helpers/piniaReset.ts | 9 +++++++++ src/views/Login.vue | 5 +++++ 2 files changed, 14 insertions(+) create mode 100644 src/helpers/piniaReset.ts diff --git a/src/helpers/piniaReset.ts b/src/helpers/piniaReset.ts new file mode 100644 index 0000000..90e2e5c --- /dev/null +++ b/src/helpers/piniaReset.ts @@ -0,0 +1,9 @@ +import { getActivePinia, type Pinia, type Store } from "pinia"; + +interface ExtendedPinia extends Pinia { + _s: Map; +} + +export const resetAllPiniaStores = () => { + (getActivePinia() as ExtendedPinia)?._s?.forEach((store: Store) => store.$reset()); +}; diff --git a/src/views/Login.vue b/src/views/Login.vue index 721aca8..15f8943 100644 --- a/src/views/Login.vue +++ b/src/views/Login.vue @@ -44,6 +44,8 @@ import { RouterLink } from "vue-router"; import Spinner from "@/components/Spinner.vue"; import SuccessCheckmark from "@/components/SuccessCheckmark.vue"; import FailureXMark from "@/components/FailureXMark.vue"; +import { getActivePinia } from "pinia"; +import { resetAllPiniaStores } from "../helpers/piniaReset";