Remove unnecessary json parse and stringify step when importing

This commit is contained in:
Misode
2024-10-24 15:57:14 +02:00
parent 9f1ae01d91
commit ee655b39e5
7 changed files with 28 additions and 102 deletions

View File

@@ -70,14 +70,14 @@ export function ProjectPanel({ onRename, onCreate, onDeleteProject }: Props) {
const path = getFilePath(file, version)
if (path === undefined) return []
if (path === 'pack.mcmeta') hasPack = true
return [[path, stringifySource(file.data)]] as [string, string][]
return [[path, stringifySource(JSON.stringify(file.data))]] as [string, string][]
})
project.unknownFiles?.forEach(({ path, data }) => {
entries.push([path, data])
})
if (!hasPack) {
const pack_format = config.versions.find(v => v.id === version)!.pack_format
entries.push(['pack.mcmeta', stringifySource({ pack: { pack_format, description: '' } })])
entries.push(['pack.mcmeta', stringifySource(JSON.stringify({ pack: { pack_format, description: '' } }, null, 2))])
}
const url = await writeZip(entries)
download.current.setAttribute('href', url)