From: Eduardo San Martin Morote Date: Wed, 26 Jul 2023 19:04:01 +0000 (+0200) Subject: fix(devtools): correctly load initial states X-Git-Tag: @pinia/nuxt@0.5.0~52 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9d49e3005ca677f8892e7af209e96d43b41e121c;p=thirdparty%2Fvuejs%2Fpinia.git fix(devtools): correctly load initial states --- diff --git a/packages/pinia/src/devtools/actions.ts b/packages/pinia/src/devtools/actions.ts index f28d8a03..2ea9af03 100644 --- a/packages/pinia/src/devtools/actions.ts +++ b/packages/pinia/src/devtools/actions.ts @@ -122,8 +122,12 @@ export async function actionGlobalOpenStateFile(pinia: Pinia) { function loadStoresState(pinia: Pinia, state: Record) { 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 } } }