experiment: better web picker using @pierre/tree (#31208)

This commit is contained in:
Luke Parker 2026-06-16 17:43:23 +02:00 committed by GitHub
commit 88f5b9a90e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
39 changed files with 1297 additions and 211 deletions

View file

@ -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"),