Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(useFileSystemAccess): updateData on modified file #3780

Merged
merged 2 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/core/useFileSystemAccess/demo.vue
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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