mirror of
https://github.com/MrPatben8/konduktor.git
synced 2026-11-27 10:22:51 +01:00
Implemented export track grid locking
This commit is contained in:
1 parent
2821ba124d
commit
9329236955
16 files changed
+196
-19
No files matched your search
+12
-3
@@ -334,6 +334,8 @@ export interface PlatformOption {
|
||||
drive_root?: boolean
|
||||
/** As an export target: only ever read on a computer, never from a drive. */
|
||||
computer_only?: boolean
|
||||
/** As an export target: its library can store a grid lock. */
|
||||
locks_grids?: boolean
|
||||
}
|
||||
|
||||
export interface EditState {
|
||||
@@ -740,6 +742,9 @@ export interface ExportSet {
|
||||
playlist_ids: string[]
|
||||
/** LOOSE tracks only — tracks a referenced playlist supplies are not listed. */
|
||||
track_ids: string[]
|
||||
/** Lock every exported grid, so Traktor does not re-analyse a track when it
|
||||
* is first loaded. Set from the run dialog and remembered here. */
|
||||
lock_grids: boolean
|
||||
created: number
|
||||
modified: number
|
||||
}
|
||||
@@ -982,7 +987,10 @@ export const api = {
|
||||
exports: () => getJSON<ExportSet[]>('/api/exports'),
|
||||
createExport: (body: { name: string; targets: string[]; destination: string }) =>
|
||||
send<ExportSet>('POST', '/api/exports', body),
|
||||
updateExport: (id: string, body: Partial<Pick<ExportSet, 'name' | 'targets' | 'destination'>>) =>
|
||||
updateExport: (
|
||||
id: string,
|
||||
body: Partial<Pick<ExportSet, 'name' | 'targets' | 'destination' | 'lock_grids'>>,
|
||||
) =>
|
||||
send<ExportSet>('PATCH', `/api/exports/${encodeURIComponent(id)}`, body),
|
||||
deleteExport: (id: string) =>
|
||||
send<{ deleted: boolean }>('DELETE', `/api/exports/${encodeURIComponent(id)}`),
|
||||
@@ -1013,8 +1021,9 @@ export const api = {
|
||||
exportTargets: () => getJSON<PlatformOption[]>('/api/export-targets'),
|
||||
exportPreview: (id: string) =>
|
||||
send<ExportPreview>('POST', `/api/exports/${encodeURIComponent(id)}/preview`, {}),
|
||||
runExport: (id: string) =>
|
||||
send<JobStatus>('POST', `/api/exports/${encodeURIComponent(id)}/run`, {}),
|
||||
// The run dialog's options travel with the click; the set remembers them.
|
||||
runExport: (id: string, body: { lock_grids?: boolean } = {}) =>
|
||||
send<JobStatus>('POST', `/api/exports/${encodeURIComponent(id)}/run`, body),
|
||||
|
||||
// ---- path remapping (per-collection OS-path prefix translation) ----
|
||||
getPathMapping: () => getJSON<PathMapping>('/api/library/path-mapping'),
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user