import { useState } from 'react' import { useQuery, useQueryClient } from '@tanstack/react-query' import { api } from '../api' import { size } from './ConvertStemsDialog' import { Modal } from './Modal' /** * Settings → Remote audio: this computer's copies of a remote library's audio. * * Everything that needs a track as a FILE — the deck, analysis, stem * separation, an export's copy onto a stick — runs here on a downloaded copy, * kept in one cache so a track is fetched once. Least recently used goes first * once the cap is reached; clearing it only costs a download the next time. */ const CAPS_GB = [2, 5, 10, 20, 50, 100] export function RemoteCacheSettings({ onClose }: { onClose: () => void }) { const qc = useQueryClient() const usage = useQuery({ queryKey: ['remote-cache'], queryFn: api.remoteCache }) const [busy, setBusy] = useState(false) const [error, setError] = useState(null) const u = usage.data const capGb = u ? Math.round(u.cap / 1024 ** 3) : null const setCap = async (gb: number) => { setError(null) try { const p = await api.patchPrefs({ remoteCacheBytes: gb * 1024 ** 3 }) qc.setQueryData(['prefs'], p) qc.invalidateQueries({ queryKey: ['remote-cache'] }) } catch (e) { setError((e as Error).message) } } const clear = async () => { setBusy(true) setError(null) try { await api.clearRemoteCache() qc.invalidateQueries({ queryKey: ['remote-cache'] }) } catch (e) { setError((e as Error).message) } finally { setBusy(false) } } return (

Remote audio

Tracks from a remote library are downloaded to this computer to be played, analysed, converted or exported, and kept so each is fetched only once.

{u ? `${size(u.bytes)} in ${u.files} file${u.files === 1 ? '' : 's'}` : 'Loading…'} {u && · {size(u.free)} free on this disk}
{error &&
{error}
}
) }