mirror of
https://github.com/MrPatben8/konduktor.git
synced 2026-11-27 10:22:51 +01:00
Track tags are now refreshed correctly when editing from within an export folder
This commit is contained in:
1 parent
86b26e3229
commit
bd35418a89
5 files changed
+32
-24
No files matched your search
+4
-15
@@ -3,6 +3,7 @@ import { useQuery, useQueryClient } from '@tanstack/react-query'
|
|||||||
import type { ColumnSizingState, SortingState, VisibilityState } from '@tanstack/react-table'
|
import type { ColumnSizingState, SortingState, VisibilityState } from '@tanstack/react-table'
|
||||||
import { CapabilitiesContext, slotLabeller } from './lib/capabilities'
|
import { CapabilitiesContext, slotLabeller } from './lib/capabilities'
|
||||||
import { writeHint } from './lib/platformCopy'
|
import { writeHint } from './lib/platformCopy'
|
||||||
|
import { invalidateTrackLists } from './lib/trackQueries'
|
||||||
import { api, type CueBatchResult, type GridBatchResult, type AutoCueSlot, type PlaylistNode, type Track, type TrackOrigin } from './api'
|
import { api, type CueBatchResult, type GridBatchResult, type AutoCueSlot, type PlaylistNode, type Track, type TrackOrigin } from './api'
|
||||||
import {
|
import {
|
||||||
COLUMN_MENU,
|
COLUMN_MENU,
|
||||||
@@ -196,9 +197,7 @@ export default function App() {
|
|||||||
api
|
api
|
||||||
.editTrack(track.id, { [field]: value })
|
.editTrack(track.id, { [field]: value })
|
||||||
.then(() => {
|
.then(() => {
|
||||||
qc.invalidateQueries({ queryKey: ['tracks'] })
|
invalidateTrackLists(qc)
|
||||||
qc.invalidateQueries({ queryKey: ['playlist'] })
|
|
||||||
qc.invalidateQueries({ queryKey: ['state'] })
|
|
||||||
qc.invalidateQueries({ queryKey: ['facets'] })
|
qc.invalidateQueries({ queryKey: ['facets'] })
|
||||||
notify('success', `Updated ${String(field)} — ${writeHintText}`)
|
notify('success', `Updated ${String(field)} — ${writeHintText}`)
|
||||||
})
|
})
|
||||||
@@ -518,12 +517,7 @@ export default function App() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!job.result) return
|
if (!job.result) return
|
||||||
qc.invalidateQueries({ queryKey: ['state'] })
|
invalidateTrackLists(qc)
|
||||||
qc.invalidateQueries({ queryKey: ['tracks'] })
|
|
||||||
qc.invalidateQueries({ queryKey: ['playlist'] })
|
|
||||||
qc.invalidateQueries({ queryKey: ['export-tracks'] })
|
|
||||||
qc.invalidateQueries({ queryKey: ['export-playlist-tracks'] })
|
|
||||||
qc.invalidateQueries({ queryKey: ['export-loose'] })
|
|
||||||
qc.invalidateQueries({ queryKey: ['facets'] })
|
qc.invalidateQueries({ queryKey: ['facets'] })
|
||||||
const cancelled = job.state === 'cancelled'
|
const cancelled = job.state === 'cancelled'
|
||||||
const plural = (n: number, w: string) => `${n} ${w}${n === 1 ? '' : 's'}`
|
const plural = (n: number, w: string) => `${n} ${w}${n === 1 ? '' : 's'}`
|
||||||
@@ -655,13 +649,8 @@ export default function App() {
|
|||||||
// Refetch whatever a track list or the deck could be showing. Throws on
|
// Refetch whatever a track list or the deck could be showing. Throws on
|
||||||
// failure (after reporting), so the confirm dialog stays open for a retry.
|
// failure (after reporting), so the confirm dialog stays open for a retry.
|
||||||
const afterBulk = (ids: string[], cuesChanged: boolean) => {
|
const afterBulk = (ids: string[], cuesChanged: boolean) => {
|
||||||
qc.invalidateQueries({ queryKey: ['state'] })
|
invalidateTrackLists(qc)
|
||||||
qc.invalidateQueries({ queryKey: ['tracks'] })
|
|
||||||
qc.invalidateQueries({ queryKey: ['playlist'] })
|
|
||||||
qc.invalidateQueries({ queryKey: ['playlists'] })
|
qc.invalidateQueries({ queryKey: ['playlists'] })
|
||||||
qc.invalidateQueries({ queryKey: ['export-tracks'] })
|
|
||||||
qc.invalidateQueries({ queryKey: ['export-playlist-tracks'] })
|
|
||||||
qc.invalidateQueries({ queryKey: ['export-loose'] })
|
|
||||||
qc.invalidateQueries({ queryKey: ['export-contents'] })
|
qc.invalidateQueries({ queryKey: ['export-contents'] })
|
||||||
qc.invalidateQueries({ queryKey: ['facets'] })
|
qc.invalidateQueries({ queryKey: ['facets'] })
|
||||||
if (cuesChanged && prepTrack && ids.includes(prepTrack.id)) setCuesRefresh((n) => n + 1)
|
if (cuesChanged && prepTrack && ids.includes(prepTrack.id)) setCuesRefresh((n) => n + 1)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { formatBpm, formatDuration } from '../lib/format'
|
|||||||
import { useCaps } from '../lib/capabilities'
|
import { useCaps } from '../lib/capabilities'
|
||||||
import { RatingStars } from './RatingStars'
|
import { RatingStars } from './RatingStars'
|
||||||
import { writeHint } from '../lib/platformCopy'
|
import { writeHint } from '../lib/platformCopy'
|
||||||
|
import { invalidateTrackLists } from '../lib/trackQueries'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
track: Track
|
track: Track
|
||||||
@@ -69,9 +70,7 @@ export function EditTagsDialog({ track, onClose, onApplied, onError }: Props) {
|
|||||||
if (Object.keys(changed).length > 0) await api.editTrack(track.id, changed)
|
if (Object.keys(changed).length > 0) await api.editTrack(track.id, changed)
|
||||||
},
|
},
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
qc.invalidateQueries({ queryKey: ['tracks'] })
|
invalidateTrackLists(qc)
|
||||||
qc.invalidateQueries({ queryKey: ['playlist'] })
|
|
||||||
qc.invalidateQueries({ queryKey: ['state'] })
|
|
||||||
qc.invalidateQueries({ queryKey: ['facets'] })
|
qc.invalidateQueries({ queryKey: ['facets'] })
|
||||||
qc.invalidateQueries({ queryKey: ['stats'] })
|
qc.invalidateQueries({ queryKey: ['stats'] })
|
||||||
onApplied(
|
onApplied(
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { useQuery, useQueryClient } from '@tanstack/react-query'
|
|||||||
import { api, type RemapPreview } from '../api'
|
import { api, type RemapPreview } from '../api'
|
||||||
import type { ToastMsg } from './Toast'
|
import type { ToastMsg } from './Toast'
|
||||||
import { Icon } from '../lib/icons'
|
import { Icon } from '../lib/icons'
|
||||||
|
import { invalidateTrackLists } from '../lib/trackQueries'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
onClose: () => void
|
onClose: () => void
|
||||||
@@ -65,7 +66,7 @@ export function PathMappingDialog({ onClose, onNotify, onError }: Props) {
|
|||||||
await api.putPathMapping({ from: from.trim(), to: to.trim() })
|
await api.putPathMapping({ from: from.trim(), to: to.trim() })
|
||||||
// Re-resolve everything that depends on the file path.
|
// Re-resolve everything that depends on the file path.
|
||||||
qc.invalidateQueries({ queryKey: ['pathMapping'] })
|
qc.invalidateQueries({ queryKey: ['pathMapping'] })
|
||||||
qc.invalidateQueries({ queryKey: ['tracks'] })
|
invalidateTrackLists(qc)
|
||||||
const cleared = !from.trim() || !to.trim()
|
const cleared = !from.trim() || !to.trim()
|
||||||
onNotify('success', cleared ? 'Path mapping cleared.' : 'Path mapping saved.')
|
onNotify('success', cleared ? 'Path mapping cleared.' : 'Path mapping saved.')
|
||||||
onClose()
|
onClose()
|
||||||
@@ -81,8 +82,8 @@ export function PathMappingDialog({ onClose, onNotify, onError }: Props) {
|
|||||||
try {
|
try {
|
||||||
const res = await api.remapPaths(from.trim(), to.trim())
|
const res = await api.remapPaths(from.trim(), to.trim())
|
||||||
// Locations changed, so track ids changed — refetch library + state.
|
// Locations changed, so track ids changed — refetch library + state.
|
||||||
qc.invalidateQueries({ queryKey: ['tracks'] })
|
invalidateTrackLists(qc)
|
||||||
qc.invalidateQueries({ queryKey: ['state'] })
|
qc.invalidateQueries({ queryKey: ['export-contents'] })
|
||||||
if (res.rewritten === 0) {
|
if (res.rewritten === 0) {
|
||||||
onNotify('warning', 'No tracks matched — nothing was rewritten.')
|
onNotify('warning', 'No tracks matched — nothing was rewritten.')
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import { setAmbientFromArt } from '../lib/ambient'
|
|||||||
import { Icon } from '../lib/icons'
|
import { Icon } from '../lib/icons'
|
||||||
import { ScratchEngine } from '../lib/scratchEngine'
|
import { ScratchEngine } from '../lib/scratchEngine'
|
||||||
import { PlaybackEngine } from '../lib/playbackEngine'
|
import { PlaybackEngine } from '../lib/playbackEngine'
|
||||||
|
import { invalidateTrackLists } from '../lib/trackQueries'
|
||||||
import { AutoCueDialog, eventLabel } from './AutoCueDialog'
|
import { AutoCueDialog, eventLabel } from './AutoCueDialog'
|
||||||
import { ContextMenu, type MenuItem } from './ContextMenu'
|
import { ContextMenu, type MenuItem } from './ContextMenu'
|
||||||
import { BpmReadout, GridEditStrip, TempoControls, TempoFold } from './GridControls'
|
import { BpmReadout, GridEditStrip, TempoControls, TempoFold } from './GridControls'
|
||||||
@@ -729,9 +730,7 @@ export function PrepStrip({
|
|||||||
|
|
||||||
const applyCueEdit = (fresh: TrackCues) => {
|
const applyCueEdit = (fresh: TrackCues) => {
|
||||||
setCueData(fresh)
|
setCueData(fresh)
|
||||||
qc.invalidateQueries({ queryKey: ['state'] })
|
invalidateTrackLists(qc)
|
||||||
qc.invalidateQueries({ queryKey: ['tracks'] })
|
|
||||||
qc.invalidateQueries({ queryKey: ['playlist'] })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Map a loop length (seconds) back to a preset beat count for the size
|
// Map a loop length (seconds) back to a preset beat count for the size
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import type { QueryClient } from '@tanstack/react-query'
|
||||||
|
|
||||||
|
// Every query that lists COLLECTION tracks, i.e. everything a track edit can
|
||||||
|
// leave stale. One list, because each edit path used to name its own and the
|
||||||
|
// export views (added later) were missing from most of them — a rating set in
|
||||||
|
// an export's playlist did not show until the view was left and re-entered.
|
||||||
|
// A new view over collection tracks belongs here.
|
||||||
|
const TRACK_LIST_KEYS = [
|
||||||
|
['tracks'],
|
||||||
|
['playlist'],
|
||||||
|
['export-tracks'],
|
||||||
|
['export-playlist-tracks'],
|
||||||
|
['export-loose'],
|
||||||
|
] as const
|
||||||
|
|
||||||
|
/** Refetch every collection track list, plus the unsaved-edits state. */
|
||||||
|
export function invalidateTrackLists(qc: QueryClient) {
|
||||||
|
for (const queryKey of TRACK_LIST_KEYS) qc.invalidateQueries({ queryKey })
|
||||||
|
qc.invalidateQueries({ queryKey: ['state'] })
|
||||||
|
}
|
||||||
Reference in new issue
Block a user