-
Notifications
You must be signed in to change notification settings - Fork 7
refactor: remove instant routing and add cache invalidation #72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: remove instant routing and add cache invalidation #72
Conversation
…router usage in forms
WalkthroughThe changes update the invoice creation flow by introducing API cache invalidation and removing artificial navigation delays. The Changes
Suggested reviewers
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/components/invoice-creator.tsx (1)
49-53: Excellent implementation of cache invalidation with immediate navigationThe async
onSuccesscallback properly invalidates the invoice cache before navigation, ensuring the dashboard displays fresh data. This eliminates the previous artificial delay while maintaining data consistency.Consider adding error handling for the cache invalidation operation:
onSuccess: async () => { toast.success("Invoice created successfully"); - await utils.invoice.getAll.invalidate(); - router.push("/dashboard"); + try { + await utils.invoice.getAll.invalidate(); + router.push("/dashboard"); + } catch (error) { + console.error("Failed to invalidate cache:", error); + // Still navigate even if cache invalidation fails + router.push("/dashboard"); + } },
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/components/invoice-creator.tsx(2 hunks)src/components/invoice-form.tsx(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/components/invoice-creator.tsx (1)
src/trpc/react.tsx (1)
api(12-12)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Install Dependencies
🔇 Additional comments (2)
src/components/invoice-form.tsx (1)
515-515: LGTM: Clean removal of router dependencyThe removal of the router dependency from the
submitAfterApprovalcallback is consistent with the architectural improvement of removing all navigation logic from the form component. This change properly centralizes navigation responsibility in the parentinvoice-creatorcomponent.src/components/invoice-creator.tsx (1)
39-39: LGTM: Proper API utils initializationThe addition of
api.useUtils()provides access to cache invalidation methods needed for the improved invoice creation flow.
bassgeta
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😎 good stuff, the pesky bug has been resolved, LGTM
MantisClone
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work 💯
Problem:
The invoice form was re-routing the moment the submit button was hit.
Solution:
Result:
CleanShot.2025-06-05.at.09.49.01.mp4
Summary by CodeRabbit
Bug Fixes
Chores