mirror of
https://github.com/misode/misode.github.io.git
synced 2026-04-24 15:47:08 +00:00
24w19a
This commit is contained in:
@@ -2,12 +2,12 @@ import type { DataModel } from '@mcschema/core'
|
||||
import { useCallback, useMemo, useRef, useState } from 'preact/hooks'
|
||||
import { Analytics } from '../../Analytics.js'
|
||||
import config from '../../Config.js'
|
||||
import { Store } from '../../Store.js'
|
||||
import { writeZip } from '../../Utils.js'
|
||||
import { DRAFT_PROJECT, disectFilePath, getFilePath, useLocale, useProject, useVersion } from '../../contexts/index.js'
|
||||
import { disectFilePath, DRAFT_PROJECT, getFilePath, useLocale, useProject, useVersion } from '../../contexts/index.js'
|
||||
import { useFocus } from '../../hooks/useFocus.js'
|
||||
import type { VersionId } from '../../services/index.js'
|
||||
import { stringifySource } from '../../services/index.js'
|
||||
import { Store } from '../../Store.js'
|
||||
import { writeZip } from '../../Utils.js'
|
||||
import { Btn } from '../Btn.js'
|
||||
import { BtnMenu } from '../BtnMenu.js'
|
||||
import { Octicon } from '../Octicon.jsx'
|
||||
@@ -44,20 +44,20 @@ export function ProjectPanel({ onRename, onCreate, onDeleteProject }: Props) {
|
||||
id: id.replaceAll('\u2215', '/'),
|
||||
}
|
||||
}
|
||||
return disectFilePath(entry)
|
||||
}, [treeViewMode])
|
||||
return disectFilePath(entry, version)
|
||||
}, [treeViewMode, version])
|
||||
|
||||
const entries = useMemo(() => project.files.flatMap(f => {
|
||||
const path = getFilePath(f)
|
||||
const path = getFilePath(f, version)
|
||||
if (!path) return []
|
||||
if (f.type === 'pack_mcmeta') return 'pack.mcmeta'
|
||||
if (treeViewMode === 'resources') {
|
||||
return [`${f.type.replaceAll('/', '\u2215')}/${f.id.replaceAll('/', '\u2215')}`]
|
||||
}
|
||||
return [path]
|
||||
}), [treeViewMode, ...project.files])
|
||||
}), [treeViewMode, version, ...project.files])
|
||||
|
||||
const selected = useMemo(() => file && getFilePath(file), [file])
|
||||
const selected = useMemo(() => file && getFilePath(file, version), [file, version])
|
||||
|
||||
const selectFile = useCallback((entry: string) => {
|
||||
const file = disectEntry(entry)
|
||||
@@ -72,7 +72,7 @@ export function ProjectPanel({ onRename, onCreate, onDeleteProject }: Props) {
|
||||
if (!download.current) return
|
||||
let hasPack = false
|
||||
const entries = project.files.flatMap(file => {
|
||||
const path = getFilePath(file)
|
||||
const path = getFilePath(file, version)
|
||||
if (path === undefined) return []
|
||||
if (path === 'pack.mcmeta') hasPack = true
|
||||
return [[path, stringifySource(file.data)]] as [string, string][]
|
||||
@@ -126,7 +126,7 @@ export function ProjectPanel({ onRename, onCreate, onDeleteProject }: Props) {
|
||||
}
|
||||
const file = disectEntry(entry)
|
||||
|
||||
return <div class={`entry ${file && getFilePath(file) === selected ? 'active' : ''} ${focused ? 'focused' : ''}`} onClick={() => selectFile(entry)} onContextMenu={onContextMenu} >
|
||||
return <div class={`entry ${file && getFilePath(file, version) === selected ? 'active' : ''} ${focused ? 'focused' : ''}`} onClick={() => selectFile(entry)} onContextMenu={onContextMenu} >
|
||||
{Octicon.file}
|
||||
<span>{entry.split('/').at(-1)}</span>
|
||||
{focused && <div class="entry-menu">
|
||||
|
||||
Reference in New Issue
Block a user