Skip to content

Cancel any pending lobby seek when accepting a challenge#2795

Merged
veloce merged 2 commits intomainfrom
cancel_seek_when_accept_challenge
Mar 19, 2026
Merged

Cancel any pending lobby seek when accepting a challenge#2795
veloce merged 2 commits intomainfrom
cancel_seek_when_accept_challenge

Conversation

@veloce
Copy link
Copy Markdown
Contributor

@veloce veloce commented Mar 19, 2026

Fixes #2638

@veloce veloce requested a review from Copilot March 19, 2026 10:27
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses issue #2638 by ensuring an active lobby matchmaking seek is cancelled before accepting a challenge, preventing the app from being matched into a second game mid-play.

Changes:

  • Cancel any pending lobby seek before accepting a challenge from the challenge requests screen.
  • Cancel any pending lobby seek before accepting a challenge from the in-app challenge confirmation flow (ChallengeService).
  • Refactor CreateGameService to take a preloaded sri and make cancelSeek() a no-op when no lobby seek is active.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
lib/src/view/user/challenge_requests_screen.dart Cancels any active lobby seek before accepting a challenge from the list UI.
lib/src/model/lobby/create_game_service.dart Passes/stores sri in the service and adjusts seek creation/cancellation behavior.
lib/src/model/challenge/challenge_service.dart Cancels any active lobby seek before accepting challenges from notification/confirm-dialog flows.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

// while accepting a challenge.
try {
await ref.read(createGameServiceProvider).cancelSeek();
} catch (_) {}
// while accepting a challenge.
try {
await ref.read(createGameServiceProvider).cancelSeek();
} catch (_) {}
Comment on lines 172 to 179
Future<void> _acceptChallenge(ChallengeId id) async {
// Cancel any pending lobby seek before accepting, to prevent being matched into a new game
// while accepting a challenge.
try {
await ref.read(createGameServiceProvider).cancelSeek();
} catch (_) {}

final fullId = await acceptChallenge(id);
@veloce veloce merged commit 0a2c979 into main Mar 19, 2026
1 check passed
@veloce veloce deleted the cancel_seek_when_accept_challenge branch March 19, 2026 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Accepting a challenge while matchmaking causes doesn't cancel matchmaking

2 participants