-
Notifications
You must be signed in to change notification settings - Fork 305
Fix Quick Match cancel button not responding #673
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: dev
Are you sure you want to change the base?
Conversation
|
🎉 Welcome @Rozerxshashank!
We appreciate your contribution! 🚀 |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the 📝 WalkthroughWalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10–15 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
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 |
|
Hi @M4dhav 👋 |
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)
lib/controllers/pair_chat_controller.dart (1)
241-260: Excellent fix for the race condition!The try/catch/finally structure with null-guarded deletion properly addresses the bug described in issue #670. The finally block ensures navigation always occurs, preventing the stuck UI, and the null check prevents the crash when cancel is tapped before the document is created.
Optional: Move
requestDocId = nullto the finally block for guaranteed cleanup.Currently, if document deletion fails (lines 244-248), the exception is caught but
requestDocIdremains non-null until navigation completes. WhileGet.offNamedUntilshould dispose the controller, moving the reset tofinallywould be more defensive:🔎 View suggested refactor
Future<void> cancelRequest() async { try { if (requestDocId != null) { await databases.deleteDocument( databaseId: masterDatabaseId, collectionId: pairRequestCollectionId, documentId: requestDocId!, ); } - - requestDocId = null; - await subscription?.close(); await userAddedSubscription?.close(); } catch (e) { log('Cancel request failed: $e'); } finally { + requestDocId = null; Get.offNamedUntil(AppRoutes.tabview, (route) => false); } }Optional: Consider independent error handling for subscriptions.
If
subscription?.close()throws on line 253,userAddedSubscription?.close()won't execute. Wrapping each in separate try/catch would ensure both closures are attempted:🔎 View alternative approach
Future<void> cancelRequest() async { try { if (requestDocId != null) { await databases.deleteDocument( databaseId: masterDatabaseId, collectionId: pairRequestCollectionId, documentId: requestDocId!, ); } } catch (e) { log('Failed to delete request document: $e'); } try { await subscription?.close(); } catch (e) { log('Failed to close subscription: $e'); } try { await userAddedSubscription?.close(); } catch (e) { log('Failed to close userAddedSubscription: $e'); } requestDocId = null; Get.offNamedUntil(AppRoutes.tabview, (route) => false); }This provides more granular error reporting and guarantees all cleanup attempts execute.
|
Please fix merge conflicts |
|
For future contributions, please strictly follow the PR Template |
|
Resolved the merge conflict and restored the safe cancelRequest implementation. |
|
Hi @M4dhav 👋 |
|
Hey @Rozerxshashank , automated tests are failing |
M4dhav
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.
fix tests failure
|
Hey @M4dhav, I’ve pushed the updated fix for PairChatController.cancelRequest. |
🐛 Bug
The Cancel button in Quick Match could be tapped before the pairing request
was fully created, leading to a null-assertion crash and causing the UI
to get stuck on the loading screen.
✅ Fix
requestDocIdfinallyblock🧪 Testing
Fixes #670
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.