mirror of
https://github.com/MrPatben8/konduktor.git
synced 2026-11-27 10:22:51 +01:00
Implemented OneLibrary track addition and removal
This commit is contained in:
1 parent
c5280a95f2
commit
7960a5a68f
20 files changed
+822
-85
No files matched your search
+18
-7
@@ -2,7 +2,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import type { ColumnSizingState, SortingState, VisibilityState } from '@tanstack/react-table'
|
||||
import { CapabilitiesContext, slotLabeller } from './lib/capabilities'
|
||||
import { writeHint } from './lib/platformCopy'
|
||||
import { removalNote, writeHint } from './lib/platformCopy'
|
||||
import { invalidateTrackLists } from './lib/trackQueries'
|
||||
import { api, type CueBatchResult, type GridBatchResult, type AutoCueSlot, type PlaylistNode, type StemBatchResult, type Track, type TrackOrigin } from './api'
|
||||
import { confirmDiscardUnsaved } from './lib/unsaved'
|
||||
@@ -578,6 +578,21 @@ export default function App() {
|
||||
qc.invalidateQueries() // refetch everything for the newly-opened collection
|
||||
}
|
||||
|
||||
// "Open for editing…" on a device: the drive becomes THE library — one library,
|
||||
// one dirty state, one SaveBar (decided 2026-10-01). Unsaved edits to the
|
||||
// current library are confirmed first, as switching library always is, and the
|
||||
// browsing copy is closed so the drive is not open twice.
|
||||
const openForEditing = async (path: string) => {
|
||||
if (!(await confirmDiscardUnsaved())) return
|
||||
try {
|
||||
await api.closeSource()
|
||||
await api.openCollection(path)
|
||||
handleOpened()
|
||||
} catch (e) {
|
||||
onError((e as Error).message)
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Convert to Stems ------------------------------------------------------
|
||||
const canStems = canEdit && !viewForeign && !!capabilities.data?.tracks.stem_convertible
|
||||
const finishStemBatch = (state: string, r: StemBatchResult | null, error: string | null) => {
|
||||
@@ -841,12 +856,7 @@ export default function App() {
|
||||
<p>
|
||||
Remove {trackNoun(ids)} from the collection and from every playlist?
|
||||
</p>
|
||||
<p className="text-faint">
|
||||
The audio {ids.length === 1 ? 'file stays' : 'files stay'} on disk. Nothing is written until you
|
||||
save{capabilities.data?.save.history
|
||||
? ', and a save can be rolled back from version history.'
|
||||
: ', and that save cannot be undone.'}
|
||||
</p>
|
||||
{capabilities.data && <p className="text-faint">{removalNote(capabilities.data, ids.length)}</p>}
|
||||
</>
|
||||
),
|
||||
confirmLabel: `Remove ${nTracks(ids.length)}`,
|
||||
@@ -1161,6 +1171,7 @@ export default function App() {
|
||||
onOpenHistory={() => setShowHistory(true)}
|
||||
onImport={() => setImporting(true)}
|
||||
onSwitchLibrary={() => setForcePicker(true)}
|
||||
onOpenLibrary={(path) => void openForEditing(path)}
|
||||
onDone={(msg) => notify('success', msg)}
|
||||
onOpenPathMapping={() => setShowPaths(true)}
|
||||
onDiscarded={() => afterBulk(prepTrack ? [prepTrack.id] : [], true)}
|
||||
|
||||
@@ -222,6 +222,8 @@ export interface SaveCapabilities {
|
||||
library_label: string
|
||||
overwrite_risk: 'none' | 'on_exit' | 'while_running'
|
||||
history: boolean
|
||||
/** Written by a Konduktor export set, whose next run replaces it. */
|
||||
managed_by_export: boolean
|
||||
}
|
||||
|
||||
/** Why a library cannot be edited. A fact — lib/platformCopy.ts words it. */
|
||||
@@ -249,6 +251,8 @@ export interface Capabilities {
|
||||
removable: boolean
|
||||
/** Tracks can be added to the library (import, add browsed files). */
|
||||
addable: boolean
|
||||
/** The library decides where added audio goes — no copy/in-place question. */
|
||||
places_audio: boolean
|
||||
/** Tracks can be converted to native-instruments STEM files. */
|
||||
stem_convertible: boolean
|
||||
/** Lower-case suffixes this library can hold — what a browsed folder lists. */
|
||||
@@ -361,6 +365,11 @@ export interface ImportPreview {
|
||||
destination: string | null
|
||||
free_bytes: number | null
|
||||
enough_space: boolean | null
|
||||
/** Set when the library places its own audio (`tracks.places_audio`): how
|
||||
* many files will be copied onto it, and how many are already there. */
|
||||
places_audio?: boolean
|
||||
copied?: number
|
||||
in_place?: number
|
||||
}
|
||||
|
||||
// ---- drives and folders ----
|
||||
|
||||
@@ -2,12 +2,18 @@ import { createPortal } from 'react-dom'
|
||||
import { useEffect, useRef, useState, type ReactNode } from 'react'
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { api, type FolderAddPreview, type FolderAddRequest, type JobStatus } from '../api'
|
||||
import { useCaps } from '../lib/capabilities'
|
||||
import { placedAudioSummary } from '../lib/platformCopy'
|
||||
import { FolderPicker } from './FolderPicker'
|
||||
|
||||
/**
|
||||
* Add browsed files to the collection — and, optionally, to a playlist or export.
|
||||
*
|
||||
* Copy vs. leave-in-place is ASKED every time, with nothing preselected: the
|
||||
* A library that places its own audio (`tracks.places_audio`, a OneLibrary
|
||||
* stick) is the exception: only files already on it can stay in place, so the
|
||||
* dialog STATES what will happen instead of asking (decided 2026-10-01).
|
||||
*
|
||||
* Otherwise copy vs. leave-in-place is ASKED every time, with nothing preselected: the
|
||||
* right answer depends on the drive (a stick is about to be unplugged) and on
|
||||
* how the DJ keeps their music, and a remembered default would quietly apply
|
||||
* last week's answer to a different drive.
|
||||
@@ -42,6 +48,11 @@ interface Props {
|
||||
|
||||
export function AddFilesDialog({ trackIds, target, onClose, onDone, onError }: Props) {
|
||||
const qc = useQueryClient()
|
||||
// The LIBRARY's capabilities (this dialog is mounted outside the browsed
|
||||
// view's swapped context). A library that places its own audio — a stick —
|
||||
// decides copy vs in place itself, so there is nothing to ask.
|
||||
const caps = useCaps()
|
||||
const places = caps.tracks.places_audio
|
||||
const [mode, setMode] = useState<'copy' | 'reference' | null>(null)
|
||||
const [folder, setFolder] = useState('')
|
||||
const [browsing, setBrowsing] = useState(false)
|
||||
@@ -62,16 +73,16 @@ export function AddFilesDialog({ trackIds, target, onClose, onDone, onError }: P
|
||||
track_ids: trackIds,
|
||||
// The preview needs A mode to size anything; "reference" costs nothing to
|
||||
// ask about and is replaced as soon as the user picks.
|
||||
mode: mode ?? 'reference',
|
||||
destination: mode === 'copy' ? folder : null,
|
||||
mode: places ? 'copy' : (mode ?? 'reference'),
|
||||
destination: !places && mode === 'copy' ? folder : null,
|
||||
playlist_id: target?.kind === 'playlist' ? target.id : null,
|
||||
export_id: target?.kind === 'export' ? target.id : null,
|
||||
}
|
||||
|
||||
const preview = useQuery<FolderAddPreview>({
|
||||
queryKey: ['folder-add-preview', trackIds, mode, folder, target?.id],
|
||||
queryKey: ['folder-add-preview', trackIds, places ? 'placed' : mode, folder, target?.id],
|
||||
queryFn: () => api.folderAddPreview(body),
|
||||
enabled: !job && (mode !== 'copy' || !!folder),
|
||||
enabled: !job && (places || mode !== 'copy' || !!folder),
|
||||
staleTime: 0,
|
||||
gcTime: 0,
|
||||
})
|
||||
@@ -146,13 +157,15 @@ export function AddFilesDialog({ trackIds, target, onClose, onDone, onError }: P
|
||||
const pct = job && job.total > 0 ? Math.min(100, (job.done / job.total) * 100) : null
|
||||
const n = trackIds.length
|
||||
const newCount = p?.importable ?? 0
|
||||
const shown = places ? 'placed' : mode
|
||||
const libraryName = places ? caps.save.app_name : 'your collection'
|
||||
const canAdd =
|
||||
!starting && mode !== null && !!p && (newCount > 0 || (!!target && p.existing.length > 0)) &&
|
||||
!starting && shown !== null && !!p && (newCount > 0 || (!!target && p.existing.length > 0)) &&
|
||||
p.enough_space !== false
|
||||
|
||||
const title = target
|
||||
? `Add ${n} track${n === 1 ? '' : 's'} to ${target.name}`
|
||||
: `Add ${n} track${n === 1 ? '' : 's'} to your collection`
|
||||
: `Add ${n} track${n === 1 ? '' : 's'} to ${libraryName}`
|
||||
|
||||
const option = (value: 'copy' | 'reference', label: string, detail: ReactNode) => (
|
||||
<label
|
||||
@@ -205,6 +218,13 @@ export function AddFilesDialog({ trackIds, target, onClose, onDone, onError }: P
|
||||
</div>
|
||||
)}
|
||||
|
||||
{places && p && (
|
||||
<div className="rounded well px-3 py-2 text-xs text-muted">
|
||||
{placedAudioSummary(caps.save, p.copied ?? 0, p.in_place ?? 0)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{!places && (
|
||||
<div className="space-y-1">
|
||||
{option(
|
||||
'copy',
|
||||
@@ -232,6 +252,7 @@ export function AddFilesDialog({ trackIds, target, onClose, onDone, onError }: P
|
||||
'Your collection points at these files. Nothing is copied.',
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{mode === 'reference' && p?.removable && (
|
||||
<div className="rounded well px-3 py-2 text-xs text-gold">
|
||||
@@ -244,15 +265,15 @@ export function AddFilesDialog({ trackIds, target, onClose, onDone, onError }: P
|
||||
<div className="text-pink">{(preview.error as Error).message}</div>
|
||||
)}
|
||||
|
||||
{mode && p && (
|
||||
{shown && p && (
|
||||
<div className="space-y-2">
|
||||
<div className="text-text">
|
||||
{newCount} new to your collection
|
||||
{mode === 'copy' && (
|
||||
{newCount} new to {libraryName}
|
||||
{shown !== 'reference' && p.total_bytes > 0 && (
|
||||
<span className="text-muted"> · {gb(p.total_bytes)} to copy</span>
|
||||
)}
|
||||
</div>
|
||||
{mode === 'copy' && p.free_bytes != null && (
|
||||
{shown !== 'reference' && p.free_bytes != null && (
|
||||
<div className={p.enough_space === false ? 'text-pink' : 'text-faint'}>
|
||||
{gb(p.free_bytes)} free
|
||||
{p.enough_space === false && ' — not enough space'}
|
||||
@@ -261,7 +282,7 @@ export function AddFilesDialog({ trackIds, target, onClose, onDone, onError }: P
|
||||
{p.existing.length > 0 && (
|
||||
<div className="rounded well px-3 py-2 text-xs text-muted">
|
||||
{p.existing.length} {p.existing.length === 1 ? 'is' : 'are'} already in
|
||||
your collection and will not be added again
|
||||
{' '}{libraryName} and will not be added again
|
||||
{target ? ` — but will still go into ${target.name}` : ''}.
|
||||
</div>
|
||||
)}
|
||||
@@ -271,7 +292,7 @@ export function AddFilesDialog({ trackIds, target, onClose, onDone, onError }: P
|
||||
there and will be skipped.
|
||||
</div>
|
||||
)}
|
||||
{mode === 'copy' && p.duplicates.length > 0 && (
|
||||
{shown !== 'reference' && p.duplicates.length > 0 && (
|
||||
<div className="rounded well px-3 py-2 text-xs text-gold">
|
||||
{p.duplicates.length} of these look like tracks your collection already
|
||||
has. The copies will be added as new entries.
|
||||
|
||||
@@ -3,6 +3,7 @@ import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { api, type Drive, type PlaylistNode } from '../api'
|
||||
import type { Source } from './Sidebar'
|
||||
import { Icon } from '../lib/icons'
|
||||
import { ContextMenu, type MenuItem } from './ContextMenu'
|
||||
|
||||
/**
|
||||
* Every drive, in the sidebar: plugged-in ones under Devices, and the computer's
|
||||
@@ -17,6 +18,11 @@ import { Icon } from '../lib/icons'
|
||||
*
|
||||
* The list genuinely changes while the app is open, so unlike everything else in
|
||||
* the sidebar this POLLS. Folder levels are fetched only when expanded.
|
||||
*
|
||||
* A device here is BROWSED, read-only, beside the loaded library. Editing one
|
||||
* means opening it as THE library ("Open for editing…": the drive row's
|
||||
* right-click menu, and a button while a device that can be edited is being
|
||||
* browsed) — one library, one dirty state, one SaveBar (decided 2026-10-01).
|
||||
*/
|
||||
|
||||
const POLL_MS = 4000
|
||||
@@ -26,9 +32,11 @@ interface Props {
|
||||
onSelect: (s: Source) => void
|
||||
onError: (msg: string) => void
|
||||
onImport: () => void
|
||||
/** Open a drive's library as THE library, to edit it. */
|
||||
onOpenLibrary: (path: string) => void
|
||||
}
|
||||
|
||||
export function DevicesSection({ source, onSelect, onError, onImport }: Props) {
|
||||
export function DevicesSection({ source, onSelect, onError, onImport, onOpenLibrary }: Props) {
|
||||
const qc = useQueryClient()
|
||||
// Which rows are expanded, by a key per row kind. Not persisted: a tree
|
||||
// reopening deep inside a drive that is no longer plugged in helps nobody.
|
||||
@@ -101,6 +109,16 @@ export function DevicesSection({ source, onSelect, onError, onImport }: Props) {
|
||||
}, [folderGone])
|
||||
|
||||
const viewingDevice = source.kind === 'device' || source.kind === 'device-playlist'
|
||||
const [menu, setMenu] = useState<{ x: number; y: number; items: MenuItem[] } | null>(null)
|
||||
// Whether the browsed device could be edited if opened as the library: a
|
||||
// FACT from its capabilities (`browsing`), never the platform's name.
|
||||
const deviceCaps = useQuery({
|
||||
queryKey: ['source-capabilities'],
|
||||
queryFn: api.sourceCapabilities,
|
||||
enabled: !!openPath,
|
||||
staleTime: Infinity,
|
||||
})
|
||||
const editable = deviceCaps.data?.readonly_cause === 'browsing'
|
||||
|
||||
const driveRow = (d: Drive, depth: number) => {
|
||||
const key = `drive:${d.path}`
|
||||
@@ -125,6 +143,16 @@ export function DevicesSection({ source, onSelect, onError, onImport }: Props) {
|
||||
expanded={expandedHere}
|
||||
onToggle={() => setRow(key, !expandedHere)}
|
||||
onClick={onClick}
|
||||
onContextMenu={
|
||||
d.library
|
||||
? (e) => {
|
||||
e.preventDefault()
|
||||
const path = d.library!.path
|
||||
setMenu({ x: e.clientX, y: e.clientY,
|
||||
items: [{ label: 'Open for editing…', onClick: () => onOpenLibrary(path) }] })
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
selected={isOpen && source.kind === 'device'}
|
||||
trailing={
|
||||
isOpen && open.data?.tracks != null ? (
|
||||
@@ -211,6 +239,16 @@ export function DevicesSection({ source, onSelect, onError, onImport }: Props) {
|
||||
Import to collection…
|
||||
</button>
|
||||
)}
|
||||
{viewingDevice && openPath && editable && (
|
||||
<button
|
||||
onClick={() => onOpenLibrary(openPath)}
|
||||
title="Open this drive as the library, so its tracks, playlists and cues can be edited"
|
||||
className="mb-1 w-full rounded-full btn-glass px-2 py-1.5 text-sm text-muted hover:text-text"
|
||||
>
|
||||
Open for editing…
|
||||
</button>
|
||||
)}
|
||||
{menu && <ContextMenu {...menu} onClose={() => setMenu(null)} />}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
@@ -235,6 +273,7 @@ function TreeRow({
|
||||
expanded,
|
||||
onToggle,
|
||||
onClick,
|
||||
onContextMenu,
|
||||
selected = false,
|
||||
trailing,
|
||||
}: {
|
||||
@@ -245,11 +284,13 @@ function TreeRow({
|
||||
expanded: boolean
|
||||
onToggle: () => void
|
||||
onClick: () => void
|
||||
onContextMenu?: (e: React.MouseEvent) => void
|
||||
selected?: boolean
|
||||
trailing?: ReactNode
|
||||
}) {
|
||||
return (
|
||||
<div
|
||||
onContextMenu={onContextMenu}
|
||||
style={{ paddingLeft: indent(depth) }}
|
||||
className={`flex w-full items-center gap-1 rounded-md py-1 pr-2 text-sm transition-colors ${
|
||||
selected ? 'is-selected text-text' : 'text-muted hover:bg-ink-800 hover:text-text'
|
||||
|
||||
@@ -2,6 +2,8 @@ import { createPortal } from 'react-dom'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { api, type ImportPreview, type JobStatus } from '../api'
|
||||
import { useCaps } from '../lib/capabilities'
|
||||
import { placedAudioSummary } from '../lib/platformCopy'
|
||||
import { FolderPicker } from './FolderPicker'
|
||||
|
||||
/**
|
||||
@@ -39,6 +41,10 @@ export function ImportDialog({ playlistId, deviceLabel, onClose, onDone, onError
|
||||
// different decisions: where your music lives, and how one import is filed
|
||||
// inside it. Joining them for display would make the toggle look like it was
|
||||
// editing the folder you picked.
|
||||
// The LIBRARY's capabilities (mounted outside the browsed device's context).
|
||||
// One that places its own audio — a stick — needs no destination.
|
||||
const caps = useCaps()
|
||||
const places = caps.tracks.places_audio
|
||||
const [baseFolder, setBaseFolder] = useState('')
|
||||
const [useSubfolder, setUseSubfolder] = useState(true)
|
||||
const [browsing, setBrowsing] = useState(false)
|
||||
@@ -166,6 +172,12 @@ export function ImportDialog({ playlistId, deviceLabel, onClose, onDone, onError
|
||||
<div className="space-y-4 px-5 py-4 text-sm">
|
||||
{!job && (
|
||||
<>
|
||||
{places && p && (
|
||||
<div className="rounded well px-3 py-2 text-xs text-muted">
|
||||
{placedAudioSummary(caps.save, p.copied ?? 0, p.in_place ?? 0)}
|
||||
</div>
|
||||
)}
|
||||
{!places && (
|
||||
<div>
|
||||
<span className="mb-1 block text-xs text-muted">Copy audio into</span>
|
||||
<div className="flex items-center gap-2">
|
||||
@@ -204,6 +216,7 @@ export function ImportDialog({ playlistId, deviceLabel, onClose, onDone, onError
|
||||
{destination}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{preview.isLoading && <div className="text-faint">Checking…</div>}
|
||||
{preview.isError && (
|
||||
@@ -216,7 +229,7 @@ export function ImportDialog({ playlistId, deviceLabel, onClose, onDone, onError
|
||||
{p.importable} track{p.importable === 1 ? '' : 's'}
|
||||
{p.playlists.length > 0 &&
|
||||
` · ${p.playlists.length} playlist${p.playlists.length === 1 ? '' : 's'}`}
|
||||
<span className="text-muted"> · {gb(p.total_bytes)} to copy</span>
|
||||
{p.total_bytes > 0 && <span className="text-muted"> · {gb(p.total_bytes)} to copy</span>}
|
||||
</div>
|
||||
|
||||
{p.free_bytes != null && (
|
||||
@@ -240,7 +253,7 @@ export function ImportDialog({ playlistId, deviceLabel, onClose, onDone, onError
|
||||
entry, so a re-import legitimately duplicates. */}
|
||||
{p.duplicates.length > 0 && (
|
||||
<div className="rounded well px-3 py-2 text-xs text-gold">
|
||||
{p.duplicates.length} of these look like tracks your collection already has.
|
||||
{p.duplicates.length} of these look like tracks {places ? caps.save.app_name : 'your collection'} already has.
|
||||
They will be added again as new entries.
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useState, type ReactNode } from 'react'
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { api } from '../api'
|
||||
import { useCaps } from '../lib/capabilities'
|
||||
import { overwriteWarning, readOnlyNotice, saveLabel } from '../lib/platformCopy'
|
||||
import { exportManagedWarning, overwriteWarning, readOnlyNotice, saveLabel } from '../lib/platformCopy'
|
||||
import { Icon } from '../lib/icons'
|
||||
import { askConfirm } from '../lib/confirm'
|
||||
|
||||
@@ -55,6 +55,7 @@ export function SaveBar({ onError, trailing, onDiscarded }: Props) {
|
||||
|
||||
const caps = useCaps()
|
||||
const warning = overwriteWarning(caps.save)
|
||||
const exportWarning = exportManagedWarning(caps.save)
|
||||
const dirty = state?.dirty ?? false
|
||||
const pending = state?.pending_stems
|
||||
const readOnly = readOnlyNotice(caps)
|
||||
@@ -81,6 +82,12 @@ export function SaveBar({ onError, trailing, onDiscarded }: Props) {
|
||||
<span>{warning}</span>
|
||||
</div>
|
||||
)}
|
||||
{dirty && exportWarning && (
|
||||
<div className="mb-2 flex gap-1.5 rounded-xl bg-gold/10 px-2.5 py-1.5 text-[11px] leading-snug text-gold">
|
||||
<Icon name="warning" size={13} className="mt-px shrink-0" />
|
||||
<span>{exportWarning}</span>
|
||||
</div>
|
||||
)}
|
||||
{/* Decided: the consequence is shown where Save is pressed, not only in
|
||||
the Stems panel — Save deletes what a Replace conversion parked. */}
|
||||
{pending && pending.parked > 0 && (
|
||||
|
||||
@@ -47,6 +47,8 @@ interface Props {
|
||||
onOpenHistory: () => void
|
||||
onImport: () => void
|
||||
onSwitchLibrary: () => void
|
||||
/** Open a drive's library as THE library (Devices' "Open for editing…"). */
|
||||
onOpenLibrary: (path: string) => void
|
||||
onDone: (msg: string) => void
|
||||
onOpenPathMapping: () => void
|
||||
/** After unsaved edits were discarded (SaveBar). */
|
||||
@@ -319,6 +321,7 @@ export function Sidebar({
|
||||
onOpenHistory,
|
||||
onImport,
|
||||
onSwitchLibrary,
|
||||
onOpenLibrary,
|
||||
onDone,
|
||||
onOpenPathMapping,
|
||||
onDiscarded,
|
||||
@@ -591,6 +594,7 @@ export function Sidebar({
|
||||
onSelect={onSelect}
|
||||
onError={onError}
|
||||
onImport={onImport}
|
||||
onOpenLibrary={onOpenLibrary}
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -94,3 +94,36 @@ export function platformAvailability(p: PlatformOption): string {
|
||||
export function browsePrompt(p: PlatformOption): string {
|
||||
return p.selects === 'directory' ? 'Find the drive to open.' : `Choose a ${p.library_label} to open.`
|
||||
}
|
||||
|
||||
// ---- a library that places its own audio (a stick) ---------------------------
|
||||
//
|
||||
// `tracks.places_audio`: the library, not the user, decides where added audio
|
||||
// goes (a OneLibrary stick can only point at files on itself), and a removed
|
||||
// track's audio goes with it. These word the consequences from that fact.
|
||||
|
||||
/** Shown while there are unsaved changes, on a library an export set wrote. */
|
||||
export function exportManagedWarning(save: SaveCapabilities): string | null {
|
||||
return save.managed_by_export
|
||||
? `${save.app_name} was written by a Konduktor export — its next run replaces edits made here.`
|
||||
: null
|
||||
}
|
||||
|
||||
/** What adding will do on a library that places its own audio. */
|
||||
export function placedAudioSummary(save: SaveCapabilities, copied: number, inPlace: number): string {
|
||||
const parts: string[] = []
|
||||
if (copied) parts.push(`${copied} ${copied === 1 ? 'file is' : 'files are'} copied to ${save.app_name}, into Contents/<Artist>/<Album>/`)
|
||||
if (inPlace) parts.push(`${inPlace} ${inPlace === 1 ? 'is' : 'are'} already on ${save.app_name} and ${inPlace === 1 ? 'stays' : 'stay'} where ${inPlace === 1 ? 'it is' : 'they are'}`)
|
||||
return parts.length ? parts.join('; ') + '.' : `Nothing needs copying to ${save.app_name}.`
|
||||
}
|
||||
|
||||
/** The removal confirm's note on what happens to the audio files. */
|
||||
export function removalNote(caps: Capabilities, count: number): string {
|
||||
const files = count === 1 ? 'Its audio and analysis files are' : 'Their audio and analysis files are'
|
||||
if (caps.tracks.places_audio) {
|
||||
return `${files} deleted from ${caps.save.app_name} when you save, and that save cannot be undone.`
|
||||
}
|
||||
const stay = count === 1 ? 'The audio file stays' : 'The audio files stay'
|
||||
return `${stay} on disk. Nothing is written until you save${caps.save.history
|
||||
? ', and a save can be rolled back from version history.'
|
||||
: ', and that save cannot be undone.'}`
|
||||
}
|
||||
Reference in new issue
Block a user