feat(fc3c): downloads Pinia store + sources.checkNow action + vitests

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-20 20:45:45 -04:00
parent e9814ca7e4
commit 397c21c88e
4 changed files with 188 additions and 0 deletions
+16
View File
@@ -70,6 +70,20 @@ export const useSourcesStore = defineStore('sources', () => {
return await api.get('/api/artists/autocomplete', { params: { q: query, limit } })
}
// FC-3c: trigger a download for one source. Returns {download_event_id,status}.
const checkingIds = ref(new Set())
async function checkNow(id) {
checkingIds.value = new Set(checkingIds.value).add(id)
try {
return await api.post(`/api/sources/${id}/check`)
} finally {
const next = new Set(checkingIds.value)
next.delete(id)
checkingIds.value = next
}
}
function sourcesByArtistGrouped() {
// returns [{artist: {id,name,slug}, sources: [...]}, ...]
const arr = byArtist.value.get(null) ?? []
@@ -92,8 +106,10 @@ export const useSourcesStore = defineStore('sources', () => {
return {
byArtist, loading, error,
allSources,
checkingIds,
loadAll, loadForArtist,
create, update, remove,
checkNow,
findOrCreateArtist, autocompleteArtist,
sourcesByArtistGrouped,
}