Skip to content

Commit

Permalink
feat: play sound when new game is started
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-anders committed Nov 15, 2024
1 parent ff98f16 commit d750319
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/src/model/game/game_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import 'package:lichess_mobile/src/model/account/account_preferences.dart';
import 'package:lichess_mobile/src/model/account/account_repository.dart';
import 'package:lichess_mobile/src/model/analysis/analysis_controller.dart';
import 'package:lichess_mobile/src/model/analysis/server_analysis_service.dart';
import 'package:lichess_mobile/src/model/auth/auth_session.dart';
import 'package:lichess_mobile/src/model/common/chess.dart';
import 'package:lichess_mobile/src/model/common/id.dart';
import 'package:lichess_mobile/src/model/common/service/move_feedback.dart';
Expand Down Expand Up @@ -113,6 +114,16 @@ class GameController extends _$GameController {

_socketEventVersion = fullEvent.socketEventVersion;

// Play "dong" sound when this is a new game and we're playing it (not spectating)
final myUserId = ref.watch(authSessionProvider)?.user.id;
final isMyGame =
myUserId != null && game.playerSideOf(myUserId) != null;
if (isMyGame &&
game.status == GameStatus.started &&
game.steps.length == 1) {
ref.read(soundServiceProvider).play(Sound.dong);
}

if (game.playable) {
_appLifecycleListener = AppLifecycleListener(
onResume: () {
Expand Down

0 comments on commit d750319

Please sign in to comment.