Implemented export track grid locking

This commit is contained in:
patben8 committed 2026-10-19 10:48:59 +02:00
1 parent 2821ba124d
commit 9329236955
16 files changed
+196 -19

No files matched your search

+26 -1
View File
@@ -36,11 +36,18 @@ export function ExportRunDialog({ set, onClose, onDone, onError }: Props) {
const qc = useQueryClient()
const [job, setJob] = useState<JobStatus | null>(null)
const [starting, setStarting] = useState(false)
// Remembered on the set (sent with the click), so a stick's next export
// starts from the same answer. Older sets without it read as on.
const [lockGrids, setLockGrids] = useState(set.lock_grids ?? true)
const pollRef = useRef<number | null>(null)
// Platform names for wording the facts the preview and result carry as ids.
const platforms = useQuery({ queryKey: ['export-targets'], queryFn: api.exportTargets })
const nameOf = (id: string) => platforms.data?.find((p) => p.platform === id)?.name ?? id
// Offered only where a target can store a lock — a stick format cannot.
const lockable = set.targets.some(
(id) => platforms.data?.find((p) => p.platform === id)?.locks_grids,
)
const preview = useQuery<ExportPreview>({
queryKey: ['export-preview', set.id],
@@ -83,7 +90,8 @@ export function ExportRunDialog({ set, onClose, onDone, onError }: Props) {
const start = async () => {
setStarting(true)
try {
setJob(await api.runExport(set.id))
setJob(await api.runExport(set.id, lockable ? { lock_grids: lockGrids } : {}))
qc.invalidateQueries({ queryKey: ['exports'] })
} catch (e) {
onError((e as Error).message)
} finally {
@@ -178,6 +186,23 @@ export function ExportRunDialog({ set, onClose, onDone, onError }: Props) {
folder’s contents to a drive’s top level.
</div>
)}
{lockable && (
<label className="flex cursor-pointer items-start gap-2.5">
<input
type="checkbox"
className="mt-0.5"
checked={lockGrids}
onChange={(e) => setLockGrids(e.target.checked)}
/>
<span className="min-w-0">
<span className="block text-sm text-text">Lock beatgrids</span>
<span className="block text-xs text-faint">
Stops tracks being re-analysed when they’re loaded, which can change the
BPM or move the grid.
</span>
</span>
</label>
)}
<div className="text-xs text-faint">
Writes a library for {set.targets.map(nameOf).join(' and ')}, sharing one copy
of every track under <span className="font-mono">Contents/</span>, in your own