From d75031991343b69fbeb5c8769db28748d373835f Mon Sep 17 00:00:00 2001 From: tom-anders <13141438+tom-anders@users.noreply.github.com> Date: Fri, 15 Nov 2024 14:20:07 +0100 Subject: [PATCH] feat: play sound when new game is started --- lib/src/model/game/game_controller.dart | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/src/model/game/game_controller.dart b/lib/src/model/game/game_controller.dart index d2a4ac3791..fa878aef4b 100644 --- a/lib/src/model/game/game_controller.dart +++ b/lib/src/model/game/game_controller.dart @@ -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'; @@ -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: () {