Skip to content

Commit beff091

Browse files
committed
fix(devtools): correctly load the state
1 parent c57a17f commit beff091

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Diff for: packages/pinia/src/devtools/actions.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ export async function actionGlobalCopyState(pinia: Pinia) {
4747
export async function actionGlobalPasteState(pinia: Pinia) {
4848
if (checkClipboardAccess()) return
4949
try {
50-
pinia.state.value = JSON.parse(await navigator.clipboard.readText())
50+
Object.assign(
51+
pinia.state.value,
52+
JSON.parse(await navigator.clipboard.readText())
53+
)
5154
toastMessage('Global state pasted from clipboard.')
5255
} catch (error) {
5356
if (checkNotFocusedError(error)) return
@@ -104,11 +107,11 @@ function getFileOpener() {
104107

105108
export async function actionGlobalOpenStateFile(pinia: Pinia) {
106109
try {
107-
const open = await getFileOpener()
110+
const open = getFileOpener()
108111
const result = await open()
109112
if (!result) return
110113
const { text, file } = result
111-
pinia.state.value = JSON.parse(text)
114+
Object.assign(pinia.state.value, JSON.parse(text))
112115
toastMessage(`Global state imported from "${file.name}".`)
113116
} catch (error) {
114117
toastMessage(

0 commit comments

Comments
 (0)