]> git.ipfire.org Git - thirdparty/vuejs/pinia.git/commitdiff
fix(devtools): correctly load the state
authorEduardo San Martin Morote <posva13@gmail.com>
Wed, 26 Jul 2023 14:30:24 +0000 (16:30 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Wed, 26 Jul 2023 14:30:24 +0000 (16:30 +0200)
packages/pinia/src/devtools/actions.ts

index 69ed2a18340aeea749b02280a475e34f1b91042e..8228d70339eaa1fa390da1a48cfd87b386429cdc 100644 (file)
@@ -47,7 +47,10 @@ export async function actionGlobalCopyState(pinia: Pinia) {
 export async function actionGlobalPasteState(pinia: Pinia) {
   if (checkClipboardAccess()) return
   try {
-    pinia.state.value = JSON.parse(await navigator.clipboard.readText())
+    Object.assign(
+      pinia.state.value,
+      JSON.parse(await navigator.clipboard.readText())
+    )
     toastMessage('Global state pasted from clipboard.')
   } catch (error) {
     if (checkNotFocusedError(error)) return
@@ -104,11 +107,11 @@ function getFileOpener() {
 
 export async function actionGlobalOpenStateFile(pinia: Pinia) {
   try {
-    const open = await getFileOpener()
+    const open = getFileOpener()
     const result = await open()
     if (!result) return
     const { text, file } = result
-    pinia.state.value = JSON.parse(text)
+    Object.assign(pinia.state.value, JSON.parse(text))
     toastMessage(`Global state imported from "${file.name}".`)
   } catch (error) {
     toastMessage(