fix(subs): stop the lock/reload on source actions + regroup the row buttons
Lock/reload: every inline source action (check / backfill / recover / toggle / remove) ended by refetching the WHOLE subscription list (store.loadAll / refresh), which blocked the UI and re-rendered the table — collapsing the expanded row, which read as "locks then resets." The action APIs already return the updated source, so the store now patches that one row in place (_patchSource / _dropSource); the post-action loadAll/refresh calls are gone. Toggling enabled, starting/stopping a backfill, recovering, and removing are now instant and leave the expansion intact. Button regroup (operator-flagged: tiny, mis-clickable, not grouped by function): - New shared SourceActions.vue used by desktop SourceRow + mobile SourceCard. - Frequent actions stay as size="small" buttons: Check, Backfill/Stop. - Low-frequency / destructive actions move into a labelled overflow (⋮) menu — Preview backfill, Recover dropped near-duplicates, Remove source — so they can't be fat-fingered, and the labels spell out recover-vs-backfill. - Edit moves next to the source URL (its identity), out of the action cluster where it sat beside Remove. - Single-source Remove now confirms (it had no guard before). Tests: store patches/drops in place without dropping the cache. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -41,6 +41,41 @@ describe('sources store', () => {
|
||||
expect(calls[0]).toContain('artist_id=7')
|
||||
})
|
||||
|
||||
it('update patches the source in place without dropping the cache', async () => {
|
||||
const s = useSourcesStore()
|
||||
s.byArtist.set(null, [
|
||||
{ id: 5, artist_id: 5, enabled: true, backfill_state: null },
|
||||
{ id: 6, artist_id: 5, enabled: true },
|
||||
])
|
||||
stubFetch(() => ({
|
||||
status: 200,
|
||||
body: { id: 5, artist_id: 5, enabled: false, backfill_state: null },
|
||||
}))
|
||||
await s.update(5, { enabled: false }, 5)
|
||||
// Cache survives (no full reload) and only source 5 changed.
|
||||
expect(s.byArtist.has(null)).toBe(true)
|
||||
const arr = s.byArtist.get(null)
|
||||
expect(arr.find(r => r.id === 5).enabled).toBe(false)
|
||||
expect(arr.find(r => r.id === 6).enabled).toBe(true)
|
||||
})
|
||||
|
||||
it('startBackfill patches backfill_state in place', async () => {
|
||||
const s = useSourcesStore()
|
||||
s.byArtist.set(null, [{ id: 5, artist_id: 5, backfill_state: null }])
|
||||
stubFetch(() => ({ status: 200, body: { id: 5, backfill_state: 'running' } }))
|
||||
await s.startBackfill(5, 5)
|
||||
expect(s.byArtist.get(null).find(r => r.id === 5).backfill_state).toBe('running')
|
||||
})
|
||||
|
||||
it('remove drops the source from the cache in place', async () => {
|
||||
const s = useSourcesStore()
|
||||
s.byArtist.set(null, [{ id: 5, artist_id: 5 }, { id: 6, artist_id: 5 }])
|
||||
stubFetch(() => ({ status: 204, body: null }))
|
||||
await s.remove(5, 5)
|
||||
expect(s.byArtist.has(null)).toBe(true)
|
||||
expect(s.byArtist.get(null).map(r => r.id)).toEqual([6])
|
||||
})
|
||||
|
||||
it('create invalidates the all-cache and the artist-cache', async () => {
|
||||
const s = useSourcesStore()
|
||||
s.byArtist.set(null, [])
|
||||
|
||||
Reference in New Issue
Block a user