mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-14 20:03:52 +00:00
fix(views): move stale-data-on-error fix to the shared query hooks
The previous Operator-only fix (checking rundown.revision) papered over a bug shared by every view loader: react-query sets status to 'error' on any failed fetch, including a background refetch, even when a prior successful fetch's data is still cached. All view loaders treated that as "no data" and blanked the whole view. Add deriveQueryStatus(), a small helper that only reports 'error' when a query has never received data, and apply it in the five base data hooks (useRundown, useRundownById, useCustomFields, useSettings, useProjectData, useViewSettings). This fixes the class of bug for every consumer (Operator, Timer, Backstage, Studio, Countdown, TimelinePage, ProjectInfo, RundownList, CuesheetTable) at the source, so the Operator-specific revision check can be reverted back to the plain status check.
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
import { deriveQueryStatus } from '../queryUtils';
|
||||
|
||||
test('keeps pending and success statuses unchanged', () => {
|
||||
expect(deriveQueryStatus('pending', undefined)).toBe('pending');
|
||||
expect(deriveQueryStatus('success', { some: 'data' })).toBe('success');
|
||||
});
|
||||
|
||||
test('keeps error status when there is no data', () => {
|
||||
expect(deriveQueryStatus('error', undefined)).toBe('error');
|
||||
});
|
||||
|
||||
test('downgrades error to success when data is still available', () => {
|
||||
expect(deriveQueryStatus('error', { some: 'data' })).toBe('success');
|
||||
expect(deriveQueryStatus('error', [])).toBe('success');
|
||||
expect(deriveQueryStatus('error', 0)).toBe('success');
|
||||
});
|
||||
Reference in New Issue
Block a user