]> git.ipfire.org Git - thirdparty/vuejs/pinia.git/commitdiff
fix(devtools): correctly load initial states
authorEduardo San Martin Morote <posva13@gmail.com>
Wed, 26 Jul 2023 19:04:01 +0000 (21:04 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Wed, 26 Jul 2023 19:04:01 +0000 (21:04 +0200)
packages/pinia/src/devtools/actions.ts

index f28d8a03062baba1875020d24fe6f24496b2254e..2ea9af0376326ec6586aac98ea70c8d1fcc93b47 100644 (file)
@@ -122,8 +122,12 @@ export async function actionGlobalOpenStateFile(pinia: Pinia) {
 function loadStoresState(pinia: Pinia, state: Record<string, unknown>) {
   for (const key in state) {
     const storeState = pinia.state.value[key]
+    // store is already instantiated, patch it
     if (storeState) {
       Object.assign(storeState, state[key])
+    } else {
+      // store is not instantiated, set the initial state
+      pinia.state.value[key] = state[key] as any
     }
   }
 }