Skip to content

Commit

Permalink
fix(devtools): correctly load the state
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Jul 26, 2023
1 parent c57a17f commit beff091
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/pinia/src/devtools/actions.ts
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit beff091

Please sign in to comment.