refactor(client): dissolve api keys and utilities stores into typed query hooks - #1295
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThe PR replaces utility-store data flows with shared React Query hooks and mutations. It updates schedule, API-key, delete-sync, Plex-label, and user-tag operations. It also standardizes numeric route IDs, removes trailing endpoint slashes, and updates service type definitions. ChangesQuery and mutation migration
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/client/features/utilities/hooks/useSchedules.ts (1)
98-155: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winWrap the returned action functions in
useCallback.
useScheduleActionsreturns new function identities on every render. Consumers place these functions inuseCallbackdependency arrays, for exampleuseApprovalScheduler.tsLine 199 ([updateScheduleAction]),useSessionMonitoring.tsLine 109, andusePlexLabels.tsLine 341. Those memoized callbacks are therefore rebuilt on every render, which defeats the memoization and causes referential churn in dependent components.The mutation objects returned by
useMutationare stable in identity, so memoizing the wrappers is straightforward.♻️ Proposed refactor
- const runScheduleNow = async (name: string) => { - try { - const data = await runMutation.mutateAsync(name) - return data.success - } catch (_err) { - return false - } - } + const runMutateAsync = runMutation.mutateAsync + const runScheduleNow = useCallback( + async (name: string) => { + try { + const data = await runMutateAsync(name) + return data.success + } catch (_err) { + return false + } + }, + [runMutateAsync], + )Apply the same pattern to
toggleScheduleStatus,updateSchedule,updateSessionMonitorSchedule, andupdateAutoResetSchedule, and importuseCallbackfromreact.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/client/features/utilities/hooks/useSchedules.ts` around lines 98 - 155, Import useCallback from React and wrap the returned action functions runScheduleNow, toggleScheduleStatus, updateSchedule, updateSessionMonitorSchedule, and updateAutoResetSchedule in useCallback with dependency arrays containing the mutation objects or callbacks they use. Preserve each function’s existing behavior and arguments while ensuring their identities remain stable across renders.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/client/features/utilities/hooks/useSchedules.ts`:
- Around line 98-155: Import useCallback from React and wrap the returned action
functions runScheduleNow, toggleScheduleStatus, updateSchedule,
updateSessionMonitorSchedule, and updateAutoResetSchedule in useCallback with
dependency arrays containing the mutation objects or callbacks they use.
Preserve each function’s existing behavior and arguments while ensuring their
identities remain stable across renders.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro Plus
Run ID: c966409e-2467-4ad9-913d-2f29d9ee29ea
⛔ Files ignored due to path filters (1)
docs/static/openapi.jsonis excluded by!docs/**
📒 Files selected for processing (28)
src/client/features/approvals/hooks/useApprovalMutations.tssrc/client/features/plex/hooks/useApprovalScheduler.tssrc/client/features/plex/hooks/useApprovalSystem.tssrc/client/features/plex/hooks/useQuotaSystem.tssrc/client/features/utilities/components/delete-sync/delete-sync-dry-run-modal.tsxsrc/client/features/utilities/hooks/useApiKeys.tssrc/client/features/utilities/hooks/useDeleteSyncActions.tssrc/client/features/utilities/hooks/useDeleteSyncDryRun.tssrc/client/features/utilities/hooks/useDeleteSyncForm.tssrc/client/features/utilities/hooks/useDeleteSyncSchedule.tssrc/client/features/utilities/hooks/usePlexLabels.tssrc/client/features/utilities/hooks/useSchedules.tssrc/client/features/utilities/hooks/useSessionMonitoring.tssrc/client/features/utilities/hooks/useSessionMonitoringQueries.tssrc/client/features/utilities/hooks/useUserTags.tssrc/client/features/utilities/hooks/useWatchlistExclusionMutations.tssrc/client/features/utilities/hooks/useWatchlistExclusions.tssrc/client/features/utilities/pages/api-keys.tsxsrc/client/features/utilities/store/apiKeysStore.tssrc/client/features/utilities/store/utilitiesStore.tssrc/client/types/api.d.tssrc/routes/v1/approval/approval.tssrc/routes/v1/session-monitoring/session-monitoring.tssrc/routes/v1/watchlist-exclusions/watchlist-exclusions.tssrc/schemas/approval/approval.schema.tssrc/schemas/session-monitoring/session-monitoring.schema.tssrc/types/radarr.types.tssrc/types/sonarr.types.ts
💤 Files with no reviewable changes (2)
- src/client/features/utilities/store/apiKeysStore.ts
- src/client/features/utilities/store/utilitiesStore.ts
Description
Related Issues
Type of Change
Testing Performed
Screenshots
Checklist
Summary by CodeRabbit
New Features
Bug Fixes