-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Refetch Promise Resolved #1767
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
base: staging
Are you sure you want to change the base?
Refetch Promise Resolved #1767
Conversation
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.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
WalkthroughThe Changes
Estimated code review effort1 (<30 minutes) Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches
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. 🪧 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.
cubic analysis
1 issue found across 1 file • Review in cubic
React with 👍 or 👎 to teach cubic. You can also tag @cubic-dev-ai to give feedback, ask questions, or re-run the review.
apps/mail/components/ui/nav-main.tsx
Outdated
|
|
||
| const onSubmit = async (data: LabelType) => { | ||
| toast.promise(createLabel(data), { | ||
| toast.promise(createLabel(data).then(()=> refetch()), { |
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.
Passing refetch() as the resolved value changes the promise chain so that any failure of refetch() will cause the entire toast.promise to reject, showing “Failed to create label” even though the label was created successfully.
Prompt for AI agents
Address the following comment on apps/mail/components/ui/nav-main.tsx at line 175:
<comment>Passing refetch() as the resolved value changes the promise chain so that any failure of refetch() will cause the entire toast.promise to reject, showing “Failed to create label” even though the label was created successfully.</comment>
<file context>
@@ -172,7 +172,7 @@ export function NavMain({ items }: NavMainProps) {
);
const onSubmit = async (data: LabelType) => {
- toast.promise(createLabel(data), {
+ toast.promise(createLabel(data).then(()=> refetch()), {
loading: 'Creating label...',
success: 'Label created successfully',
error: 'Failed to create label',
@@ -253,7 +253,6 @@ export function NavMain({ items }: NavMainProps) {
</Button>
}
onSubmit={onSubmit}
- onSuccess={refetch}
/>
) : activeAccount?.providerId === 'microsoft' ? null : null}
</div>
</file context>
| toast.promise(createLabel(data).then(()=> refetch()), { | |
| toast.promise(createLabel(data).then((res) => { refetch(); return res; }), { |
| refetch(); | ||
| }), { | ||
| loading: 'Creating label...', | ||
| success: 'Label created successfully', |
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.
toast.promise has a key finally, your promise doesn't even need to be called in the first argument
Fix: Resolve issue #1748 – Label creation now auto-refreshes the list after successful mutation
Previously, the new label was added successfully but the label list did not update automatically, requiring a manual page refresh. This has been fixed by triggering a query refetch when the label creation promise resolves.
Type of Change
Areas Affected
Testing Done
Security Considerations
Checklist
Additional Notes
This resolves issue #1748 where newly created labels did not appear automatically. The label list is now refreshed upon successful creation without requiring a manual page reload.
Screenshots/Recordings
Add screenshots or recordings here if applicable.
By submitting this pull request, I confirm that my contribution is made under the terms of the project's license.
Summary by cubic
Fixed an issue where new labels did not appear automatically after creation by refreshing the label list once the label is added.
Summary by CodeRabbit