From 0bdb8c57d7421cfd2a5ca4f476f6caf9f3cb946c Mon Sep 17 00:00:00 2001 From: tom-anders <13141438+tom-anders@users.noreply.github.com> Date: Tue, 8 Apr 2025 21:47:21 +0200 Subject: [PATCH 1/2] fix: disable chat if account is in kid mode --- lib/src/model/account/account_repository.dart | 5 +++++ lib/src/view/game/game_body.dart | 10 ++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/src/model/account/account_repository.dart b/lib/src/model/account/account_repository.dart index a542003c20..f68800da99 100644 --- a/lib/src/model/account/account_repository.dart +++ b/lib/src/model/account/account_repository.dart @@ -35,6 +35,11 @@ Future accountUser(Ref ref) async { return ref.watch(accountProvider.selectAsync((user) => user?.lightUser)); } +@riverpod +Future kidMode(Ref ref) async { + return ref.watch(accountProvider.selectAsync((user) => user?.kid ?? false)); +} + @riverpod Future> accountActivity(Ref ref) async { final session = ref.watch(authSessionProvider); diff --git a/lib/src/view/game/game_body.dart b/lib/src/view/game/game_body.dart index 46c9caa918..a3219a33b4 100644 --- a/lib/src/view/game/game_body.dart +++ b/lib/src/view/game/game_body.dart @@ -100,12 +100,14 @@ class GameBody extends ConsumerWidget { final enableChat = ref.watch( gamePreferencesProvider.select((prefs) => prefs.enableChat ?? false), ); + final kidModeAsync = ref.watch(kidModeProvider); final gameStateAsync = ref.watch(ctrlProvider); return gameStateAsync.when( data: (gameState) { - final isChatEnabled = enableChat && !gameState.isZenModeActive; + final isChatEnabled = + enableChat && !gameState.isZenModeActive && kidModeAsync.valueOrNull == false; if (isChatEnabled) { ref.listen( chatControllerProvider(id), @@ -430,11 +432,15 @@ class _GameBottomBar extends ConsumerWidget { final gameStateAsync = ref.watch(gameControllerProvider(id)); final chatStateAsync = gamePrefs.enableChat == true ? ref.watch(chatControllerProvider(id)) : null; + final kidModeAsync = ref.watch(kidModeProvider); return PlatformBottomBar( children: gameStateAsync.when( data: (gameState) { - final isChatEnabled = chatStateAsync != null && !gameState.isZenModeActive; + final isChatEnabled = + chatStateAsync != null && + !gameState.isZenModeActive && + kidModeAsync.valueOrNull == false; final chatUnreadLabel = isChatEnabled From fa7209bd28159c6cf07582dbbb145f38f71e537f Mon Sep 17 00:00:00 2001 From: tom-anders <13141438+tom-anders@users.noreply.github.com> Date: Wed, 9 Apr 2025 18:44:43 +0200 Subject: [PATCH 2/2] completely hide chat in kid mode --- lib/src/view/game/game_body.dart | 43 ++++++++++++++++---------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/lib/src/view/game/game_body.dart b/lib/src/view/game/game_body.dart index a3219a33b4..d7fa07a7e6 100644 --- a/lib/src/view/game/game_body.dart +++ b/lib/src/view/game/game_body.dart @@ -585,27 +585,28 @@ class _GameBottomBar extends ConsumerWidget { orElse: () => null, ), ), - BottomBarButton( - label: context.l10n.chat, - onTap: - isChatEnabled - ? () { - Navigator.of(context).push( - MessageScreen.buildRoute( - context, - title: UserFullNameWidget(user: gameState.game.opponent?.user), - me: gameState.game.me?.user, - id: id, - ), - ); - } - : null, - icon: - Theme.of(context).platform == TargetPlatform.iOS - ? CupertinoIcons.chat_bubble - : Icons.chat_bubble_outline, - badgeLabel: chatUnreadLabel, - ), + if (kidModeAsync.valueOrNull == false) + BottomBarButton( + label: context.l10n.chat, + onTap: + isChatEnabled + ? () { + Navigator.of(context).push( + MessageScreen.buildRoute( + context, + title: UserFullNameWidget(user: gameState.game.opponent?.user), + me: gameState.game.me?.user, + id: id, + ), + ); + } + : null, + icon: + Theme.of(context).platform == TargetPlatform.iOS + ? CupertinoIcons.chat_bubble + : Icons.chat_bubble_outline, + badgeLabel: chatUnreadLabel, + ), RepeatButton( onLongPress: gameState.canGoBackward ? () => _moveBackward(ref) : null, child: BottomBarButton(