feat(web): adminRequests cache key + staleTime polish
- qk.adminRequests defaults to status='all' when no filter is set; the unfiltered endpoint returns every status, so caching it as 'pending' was a latent mismatch. - 60s staleTime on lidarrConfig + myRequests — both are session-stable enough that refetching on every consumer-page mount produced needless flicker.
This commit is contained in:
@@ -215,8 +215,11 @@ describe('qk admin keys', () => {
|
|||||||
test('lidarrRootFolders key', () => {
|
test('lidarrRootFolders key', () => {
|
||||||
expect(qk.lidarrRootFolders()).toEqual(['lidarrRootFolders']);
|
expect(qk.lidarrRootFolders()).toEqual(['lidarrRootFolders']);
|
||||||
});
|
});
|
||||||
test('adminRequests key defaults to pending when status omitted', () => {
|
test('adminRequests key uses "all" when status omitted', () => {
|
||||||
expect(qk.adminRequests()).toEqual(['adminRequests', { status: 'pending' }]);
|
// listAdminRequests sends no status param when called without one (returns
|
||||||
|
// every status), so the cache key must distinguish that from any specific
|
||||||
|
// status — otherwise an unfiltered call would falsely cache as `pending`.
|
||||||
|
expect(qk.adminRequests()).toEqual(['adminRequests', { status: 'all' }]);
|
||||||
});
|
});
|
||||||
test('adminRequests key includes the status filter', () => {
|
test('adminRequests key includes the status filter', () => {
|
||||||
expect(qk.adminRequests('approved')).toEqual([
|
expect(qk.adminRequests('approved')).toEqual([
|
||||||
|
|||||||
@@ -72,7 +72,8 @@ export async function rejectRequest(
|
|||||||
export function createLidarrConfigQuery() {
|
export function createLidarrConfigQuery() {
|
||||||
return createQuery({
|
return createQuery({
|
||||||
queryKey: qk.lidarrConfig(),
|
queryKey: qk.lidarrConfig(),
|
||||||
queryFn: getLidarrConfig
|
queryFn: getLidarrConfig,
|
||||||
|
staleTime: 60_000
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ export const qk = {
|
|||||||
lidarrQualityProfiles: () => ['lidarrQualityProfiles'] as const,
|
lidarrQualityProfiles: () => ['lidarrQualityProfiles'] as const,
|
||||||
lidarrRootFolders: () => ['lidarrRootFolders'] as const,
|
lidarrRootFolders: () => ['lidarrRootFolders'] as const,
|
||||||
adminRequests: (status?: string) =>
|
adminRequests: (status?: string) =>
|
||||||
['adminRequests', { status: status ?? 'pending' }] as const,
|
['adminRequests', { status: status ?? 'all' }] as const,
|
||||||
};
|
};
|
||||||
|
|
||||||
export function createArtistsQuery(sort: ArtistSort) {
|
export function createArtistsQuery(sort: ArtistSort) {
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ export async function cancelRequest(id: string): Promise<LidarrRequest> {
|
|||||||
export function createMyRequestsQuery() {
|
export function createMyRequestsQuery() {
|
||||||
return createQuery({
|
return createQuery({
|
||||||
queryKey: qk.myRequests(),
|
queryKey: qk.myRequests(),
|
||||||
queryFn: listMyRequests
|
queryFn: listMyRequests,
|
||||||
|
staleTime: 60_000
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user