fix(download): keep iOS home screen app saves in-app via the share sheet (#353)

* fix(download): keep iOS home screen app saves in-app via the share sheet

* fix: apply CodeRabbit auto-fixes
This commit is contained in:
Chris Scott authored and GitHub committed 2026-09-18 22:35:54 -04:00
1 parent b21c80c9e8
commit 7a3c5229df
9 files changed
+203 -48

No files matched your search

@@ -3,6 +3,7 @@ import { Button } from '@/components/ui/button'
import { Download, X, Edit3, Save, X as XIcon, WrapText, Eye, Code } from 'lucide-react'
import type { FileInfo } from '@/types/files'
import { getFileApiUrl } from '@/api/files'
import { saveFileFromUrl } from '@/lib/download'
import { VirtualizedTextView, type VirtualizedTextViewHandle } from '@/components/ui/virtualized-text-view'
import { MarkdownRenderer } from './MarkdownRenderer'
@@ -94,12 +95,7 @@ export const FilePreview = memo(function FilePreview({ file, hideHeader = false,
}
const handleDownload = () => {
const link = document.createElement('a')
link.href = getFileApiUrl(file.path, { params: { download: true } })
link.download = file.name
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
void saveFileFromUrl(getFileApiUrl(file.path, { params: { download: true } }), file.name)
}
const decodeBase64 = (base64: string): string => {
@@ -4,6 +4,7 @@ import { Button } from '@/components/ui/button'
import { Input } from '@/components/ui/input'
import { DeleteDialog } from '@/components/ui/delete-dialog'
import { getFileApiUrl } from '@/api/files'
import { saveFileFromUrl } from '@/lib/download'
import {
File,
Folder,
@@ -95,13 +96,7 @@ function TreeNode({ file, level, onFileSelect, onDirectoryClick, selectedFile, o
const handleDownload = () => {
if (file.isDirectory) return
const downloadUrl = getFileApiUrl(file.path, { params: { download: true } })
const link = document.createElement('a')
link.href = downloadUrl
link.download = file.name
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
void saveFileFromUrl(getFileApiUrl(file.path, { params: { download: true } }), file.name)
}
const getFileIcon = () => {
@@ -24,6 +24,7 @@ import { useServerHealth } from '@/hooks/useServerHealth'
import { useOpenCodeServerActions } from '@/hooks/useOpenCodeServerActions'
import { parseJsonc, hasJsoncComments } from '@/lib/jsonc'
import { showToast } from '@/lib/toast'
import { saveFile } from '@/lib/download'
import { invalidateConfigCaches } from '@/lib/queryInvalidation'
import { getOpenCodeApiErrorMessage } from '@/lib/opencode-errors'
import { FetchError } from '@/api/fetchWrapper'
@@ -308,12 +309,7 @@ export function OpenCodeConfigManager() {
const content = config.rawContent || JSON.stringify(config.content, null, 2)
const extension = config.rawContent && hasJsoncComments(config.rawContent) ? 'jsonc' : 'json'
const blob = new Blob([content], { type: 'application/json' })
const url = URL.createObjectURL(blob)
const a = document.createElement('a')
a.href = url
a.download = `${config.name}.${extension}`
a.click()
URL.revokeObjectURL(url)
void saveFile(blob, `${config.name}.${extension}`)
}