experiment: better web picker using @pierre/tree (#31208)
This commit is contained in:
parent
25cb2be619
commit
88f5b9a90e
39 changed files with 1297 additions and 211 deletions
|
|
@ -78,6 +78,7 @@ const listenForDeepLinks = () => {
|
|||
}
|
||||
|
||||
const createPlatform = (): Platform => {
|
||||
const attachmentPaths = new WeakMap<File, string>()
|
||||
const os = (() => {
|
||||
const ua = navigator.userAgent
|
||||
if (ua.includes("Mac")) return "macos"
|
||||
|
|
@ -153,13 +154,19 @@ const createPlatform = (): Platform => {
|
|||
if (!result) return
|
||||
try {
|
||||
for (const file of result.files) {
|
||||
await onFile(new File([await window.api.readPickedFile(result.token, file.path)], file.name))
|
||||
const selected = new File([await window.api.readPickedFile(result.token, file.path)], file.name)
|
||||
attachmentPaths.set(selected, file.path)
|
||||
await onFile(selected)
|
||||
}
|
||||
} finally {
|
||||
await window.api.releasePickedFiles(result.token)
|
||||
}
|
||||
},
|
||||
|
||||
getPathForFile(file) {
|
||||
return attachmentPaths.get(file) ?? window.api.getPathForFile(file)
|
||||
},
|
||||
|
||||
async saveFilePickerDialog(opts) {
|
||||
return window.api.saveFilePicker({
|
||||
title: opts?.title ?? t("desktop.dialog.saveFile"),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue