- Created QueryClient singleton (queryClientSingleton.ts): - Provides global access to QueryClient for state invalidation - Set in main.tsx after QueryClient creation - Updated invalidateQueries() to use QueryClient directly: - Replaced custom event system with direct QueryClient.invalidateQueries() - Added query key mapping for all resource types - Event system kept as fallback if QueryClient not available - Updated invalidateStore() for Library Store: - Removed clearItems() call (method doesn't exist, domain data migrated to React Query) - Library Store now only contains UI state (filters) - React Query cache invalidation handles refetching - Query keys mapped: - tracks: ['tracks'], ['track'], ['library'] - playlists: ['playlists'], ['playlist'] - users: ['users'], ['user'], ['auth'], ['userProfile'] - conversations: ['conversations'], ['conversation'], ['chat'], ['chatConversations'] - roles: ['roles'], ['role'] - library: ['library'], ['tracks'], ['favorites'], ['libraryItems'] - auth: ['auth'], ['user'] - Action 4.6.1.5 complete
27 lines
735 B
TypeScript
27 lines
735 B
TypeScript
/**
|
|
* QueryClient Singleton
|
|
* Action 4.6.1.5: Provide global access to QueryClient for state invalidation
|
|
*
|
|
* This singleton allows stateInvalidation to access QueryClient without
|
|
* needing to be inside a React component.
|
|
*/
|
|
|
|
import type { QueryClient } from '@tanstack/react-query';
|
|
|
|
let queryClientInstance: QueryClient | null = null;
|
|
|
|
/**
|
|
* Set the QueryClient instance
|
|
* Should be called once in main.tsx after creating the QueryClient
|
|
*/
|
|
export function setQueryClient(client: QueryClient): void {
|
|
queryClientInstance = client;
|
|
}
|
|
|
|
/**
|
|
* Get the QueryClient instance
|
|
* Returns null if not set (should not happen in production)
|
|
*/
|
|
export function getQueryClient(): QueryClient | null {
|
|
return queryClientInstance;
|
|
}
|