From 184442a5ffe5206e44d5a9dec990f9353d5f0f2f Mon Sep 17 00:00:00 2001 From: Sofanyas Genene <123987957+Sofanyas@users.noreply.github.com> Date: Thu, 10 Apr 2025 14:50:55 -0400 Subject: [PATCH] =?UTF-8?q?added=20robot=20animation=20and=20message=20to?= =?UTF-8?q?=20instruct=20user=20to=20wait=20after=20too=20=E2=80=A6=20(#24?= =?UTF-8?q?15)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * added robot animation and message to instruct user to wait after too many join with code attempts * chore: formatting * replaced hardcoded text with intl_en.arb * Resolving missing import * generated * chore: formatting --------- Co-authored-by: ggurdin Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- assets/l10n/intl_en.arb | 4 +- .../spaces/controllers/space_controller.dart | 57 ++++++++++++++++--- 2 files changed, 52 insertions(+), 9 deletions(-) diff --git a/assets/l10n/intl_en.arb b/assets/l10n/intl_en.arb index 56f7ebce9..37c7031ed 100644 --- a/assets/l10n/intl_en.arb +++ b/assets/l10n/intl_en.arb @@ -4859,5 +4859,7 @@ "publicSpacesTitle": "Learning communities", "askToJoin": "Ask to join", "emptyChatWarningTitle": "Chat is empty", - "emptyChatWarningDesc": "You haven't invited anyone to your chat. Go to Chat settings to invite your contacts or the Bot. You can also do this later." + "emptyChatWarningDesc": "You haven't invited anyone to your chat. Go to Chat settings to invite your contacts or the Bot. You can also do this later.", + "areYouLikeMe": "Are you like me?", + "tryAgainLater": "Too many attempts made. Please try again in 5 minutes." } \ No newline at end of file diff --git a/lib/pangea/spaces/controllers/space_controller.dart b/lib/pangea/spaces/controllers/space_controller.dart index 3005862b5..b57b9cc2c 100644 --- a/lib/pangea/spaces/controllers/space_controller.dart +++ b/lib/pangea/spaces/controllers/space_controller.dart @@ -16,12 +16,13 @@ import 'package:fluffychat/pangea/common/utils/error_handler.dart'; import 'package:fluffychat/pangea/common/utils/firebase_analytics.dart'; import 'package:fluffychat/widgets/future_loading_dialog.dart'; import 'package:fluffychat/widgets/matrix.dart'; +import '../../bot/widgets/bot_face_svg.dart'; import '../../common/controllers/base_controller.dart'; class ClassController extends BaseController { late PangeaController _pangeaController; - //Storage Initialization + // Storage Initialization final GetStorage chatBox = GetStorage("chat_list_storage"); final GetStorage linkBox = GetStorage("link_storage"); static final GetStorage _classStorage = GetStorage('class_storage'); @@ -121,7 +122,8 @@ class ClassController extends BaseController { ); if (knockResponse.statusCode == 429) { - throw L10n.of(context).tooManyRequest; + await _showTooManyRequestsPopup(context); + return null; } if (knockResponse.statusCode != 200) { throw notFoundError ?? L10n.of(context).unableToFindClass; @@ -197,12 +199,51 @@ class ClassController extends BaseController { }, ); } + } - // P-EPIC - // prereq - server needs ability to invite to private room. how? - // does server api have ability with admin token? - // is application service needed? - // BE - check class code and if class code is correct, invite student to room - // FE - look for invite from room and automatically accept + Future _showTooManyRequestsPopup(BuildContext context) async { + showDialog( + context: context, + builder: (BuildContext context) { + return Dialog( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(12.0), + ), + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + const BotFace( + width: 100, + expression: BotExpression.idle, + ), + const SizedBox(height: 16), + Text( + // "Are you like me?", + L10n.of(context).areYouLikeMe, + style: Theme.of(context).textTheme.titleLarge, + textAlign: TextAlign.center, + ), + const SizedBox(height: 8), + Text( + // "Too many attempts made. Please try again in 5 minutes.", + L10n.of(context).tryAgainLater, + style: Theme.of(context).textTheme.bodyMedium, + textAlign: TextAlign.center, + ), + const SizedBox(height: 16), + TextButton( + onPressed: () { + Navigator.of(context).pop(); + }, + child: const Text("Close"), + ), + ], + ), + ), + ); + }, + ); } }