Skip to content

Commit

Permalink
fix(useFileSystemAccess): updateData on modified file (#3780)
Browse files Browse the repository at this point in the history
  • Loading branch information
PhE committed Feb 20, 2024
1 parent 9b8ed55 commit 668ca14
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 3 additions & 0 deletions packages/core/useFileSystemAccess/demo.vue
Expand Up @@ -37,6 +37,9 @@ async function onSave() {
<button @click="res.open()">
Open
</button>
<button @click="res.updateData()">
Update
</button>
<button @click="res.create()">
New file
</button>
Expand Down
3 changes: 1 addition & 2 deletions packages/core/useFileSystemAccess/index.ts
Expand Up @@ -121,7 +121,6 @@ export function useFileSystemAccess(options: UseFileSystemAccessOptions = {}): U
return
const [handle] = await window.showOpenFilePicker({ ...toValue(options), ..._options })
fileHandle.value = handle
await updateFile()
await updateData()
}

Expand All @@ -130,7 +129,6 @@ export function useFileSystemAccess(options: UseFileSystemAccessOptions = {}): U
return
fileHandle.value = await (window as FileSystemAccessWindow).showSaveFilePicker({ ...options, ..._options })
data.value = undefined
await updateFile()
await updateData()
}

Expand Down Expand Up @@ -170,6 +168,7 @@ export function useFileSystemAccess(options: UseFileSystemAccessOptions = {}): U
}

async function updateData() {
await updateFile()
const type = toValue(dataType)
if (type === 'Text')
data.value = await file.value?.text()
Expand Down

0 comments on commit 668ca14

Please sign in to comment.