refactor(fe): migrate plex/messaging/admin/downloads/notifications to qk (R7 S2b)
Extend lib/queryKeys.ts to the remaining ~34 key roots and migrate every remaining literal (queryKey: [...] AND the positional useLiveQuery keys) in 36 files. All ~200 React Query keys across the app now route through the factory; zero raw key literals remain outside queryKeys.ts. The heterogeneous composite plex keys (plex-library/facets/collections/ playlists carry a filters object, a ratingKeys array, or a union/group discriminator) take a variadic pass-through — the factory centralizes the ROOT string; single-id keys stay precisely typed. Nullable keys (thread, playlist, ytSearch) accept null so a null segment is preserved. Pure substitution — byte-identical key arrays, so TanStack prefix matching is unchanged. Gate green: typecheck (app+node+e2e), eslint (0 err), prettier, 68 vitest. Runtime-verified on a fresh dev server: Feed + Plex modules load, feed/facets/tags/my-status/plex-library/plex-facets/ plex-collections/plex-playlists all 200, full UI renders.
This commit is contained in:
@@ -41,4 +41,62 @@ export const qk = {
|
||||
id !== undefined ? (["playlist", id] as const) : (["playlist"] as const),
|
||||
playlistMembership: (videoId: string) => ["playlist-membership", videoId] as const,
|
||||
savedViews: () => ["saved-views"] as const,
|
||||
|
||||
// --- account / misc (R7 S2b) --- (me/myStatus/tags already declared as shared roots above)
|
||||
accounts: () => ["accounts"] as const,
|
||||
version: () => ["version"] as const,
|
||||
setupStatus: () => ["setup-status"] as const,
|
||||
myUsage: () => ["my-usage"] as const,
|
||||
scheduler: () => ["scheduler"] as const,
|
||||
|
||||
// --- notifications ---
|
||||
notifications: () => ["notifications"] as const,
|
||||
notifUnread: () => ["notif-unread"] as const,
|
||||
|
||||
// --- messaging ---
|
||||
conversations: () => ["conversations"] as const,
|
||||
thread: (partnerId: number | null) => ["thread", partnerId] as const,
|
||||
messageKey: () => ["message-key"] as const,
|
||||
messageUnread: () => ["message-unread"] as const,
|
||||
messageUsers: () => ["message-users"] as const,
|
||||
shareRecipients: () => ["share-recipients"] as const,
|
||||
|
||||
// --- downloads ---
|
||||
downloads: () => ["downloads"] as const,
|
||||
downloadsShared: () => ["downloads-shared"] as const,
|
||||
downloadIndex: () => ["download-index"] as const,
|
||||
downloadUsage: () => ["download-usage"] as const,
|
||||
downloadProfiles: () => ["download-profiles"] as const,
|
||||
downloadLinks: (jobId: number) => ["download-links", jobId] as const,
|
||||
dlQuota: (userId: number) => ["dl-quota", userId] as const,
|
||||
storyboard: (jobId: number) => ["storyboard", jobId] as const,
|
||||
|
||||
// --- admin ---
|
||||
adminUsers: () => ["admin-users"] as const,
|
||||
adminInvites: () => ["admin-invites"] as const,
|
||||
adminConfig: () => ["admin-config"] as const,
|
||||
adminAudit: () => ["admin-audit"] as const,
|
||||
adminStorage: () => ["admin-storage"] as const,
|
||||
adminDownloads: () => ["admin-downloads"] as const,
|
||||
adminQuota: (days: number) => ["admin-quota", days] as const,
|
||||
demoWhitelist: () => ["demo-whitelist"] as const,
|
||||
|
||||
// --- plex ---
|
||||
// The composite plex keys carry a heterogeneous arg list (a filters object, a ratingKeys
|
||||
// array, a "union"/"group"/"contains" discriminator), so they take a variadic pass-through:
|
||||
// the value this factory centralizes is the ROOT string, and TanStack keys are `unknown[]`
|
||||
// anyway. Single-id plex keys stay precisely typed.
|
||||
plex: () => ["plex"] as const,
|
||||
plexWatchLink: () => ["plex-watch-link"] as const,
|
||||
plexLibrary: (...rest: unknown[]) => ["plex-library", ...rest],
|
||||
plexShow: (showId?: string) =>
|
||||
showId !== undefined ? (["plex-show", showId] as const) : (["plex-show"] as const),
|
||||
plexItem: (id: string) => ["plex-item", id] as const,
|
||||
plexPlaylists: (...rest: unknown[]) => ["plex-playlists", ...rest],
|
||||
plexPlaylist: (playlistId: number) => ["plex-playlist", playlistId] as const,
|
||||
plexCollections: (...rest: unknown[]) => ["plex-collections", ...rest],
|
||||
// facetKey is a filters-derived OBJECT segment (not a scalar), so this key is heterogeneous too.
|
||||
plexFacets: (...rest: unknown[]) => ["plex-facets", ...rest],
|
||||
plexPeopleCards: (scope: string, actors: string[]) =>
|
||||
["plex-people-cards", scope, actors] as const,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user