From 2b1b882e46cef572203ed2df7e7e16256889426f Mon Sep 17 00:00:00 2001 From: sidhdhi canopas Date: Tue, 30 Apr 2024 15:17:49 +0530 Subject: [PATCH] fix running match stat not updated --- data/lib/service/match/match_service.dart | 47 ++++++++++--------- khelo/lib/ui/flow/home/home_screen.dart | 2 +- .../phone_verification_screen.dart | 5 +- .../phone_verification_view_model.dart | 5 +- 4 files changed, 34 insertions(+), 25 deletions(-) diff --git a/data/lib/service/match/match_service.dart b/data/lib/service/match/match_service.dart index d0299013..caa9052e 100644 --- a/data/lib/service/match/match_service.dart +++ b/data/lib/service/match/match_service.dart @@ -221,26 +221,29 @@ class MatchService { for (QueryDocumentSnapshot mainDoc in snapshot.docs) { Map mainDocData = mainDoc.data() as Map; - AddEditMatchRequest match = AddEditMatchRequest.fromJson(mainDocData); - - List teams = await getTeamsList(match.teams); - matches.add(MatchModel( - id: match.id, - teams: teams, - match_type: match.match_type, - number_of_over: match.number_of_over, - over_per_bowler: match.over_per_bowler, - city: match.city, - ground: match.ground, - start_time: match.start_time, - created_by: match.created_by, - ball_type: match.ball_type, - pitch_type: match.pitch_type, - match_status: match.match_status, - toss_winner_id: match.toss_winner_id, - toss_decision: match.toss_decision, - current_playing_team_id: match.current_playing_team_id, - )); + if (mainDocData['match_status'] == 2) { + AddEditMatchRequest match = + AddEditMatchRequest.fromJson(mainDocData); + + List teams = await getTeamsList(match.teams); + matches.add(MatchModel( + id: match.id, + teams: teams, + match_type: match.match_type, + number_of_over: match.number_of_over, + over_per_bowler: match.over_per_bowler, + city: match.city, + ground: match.ground, + start_time: match.start_time, + created_by: match.created_by, + ball_type: match.ball_type, + pitch_type: match.pitch_type, + match_status: match.match_status, + toss_winner_id: match.toss_winner_id, + toss_decision: match.toss_decision, + current_playing_team_id: match.current_playing_team_id, + )); + } } controller.add(matches); } catch (error, stack) { @@ -306,14 +309,14 @@ class MatchService { controller.add(matchModel); } catch (error, stack) { - controller.addError(AppError.fromError(error,stack)); + controller.addError(AppError.fromError(error, stack)); } } else { controller.close(); subscription?.cancel(); } }, onError: (error, stack) { - controller.addError(AppError.fromError(error,stack)); + controller.addError(AppError.fromError(error, stack)); }); return controller.stream; diff --git a/khelo/lib/ui/flow/home/home_screen.dart b/khelo/lib/ui/flow/home/home_screen.dart index f18a12c5..864855e0 100644 --- a/khelo/lib/ui/flow/home/home_screen.dart +++ b/khelo/lib/ui/flow/home/home_screen.dart @@ -64,7 +64,7 @@ class HomeScreen extends ConsumerWidget { itemCount: state.matches.length, itemBuilder: (context, index) { return _matchCell( - context, state.matches[(index % state.matches.length).toInt()]); + context, state.matches[index]); }, ); } diff --git a/khelo/lib/ui/flow/sign_in/phone_verification/phone_verification_screen.dart b/khelo/lib/ui/flow/sign_in/phone_verification/phone_verification_screen.dart index 9f39c650..d20c66fe 100644 --- a/khelo/lib/ui/flow/sign_in/phone_verification/phone_verification_screen.dart +++ b/khelo/lib/ui/flow/sign_in/phone_verification/phone_verification_screen.dart @@ -42,6 +42,7 @@ class _PhoneVerificationScreenState () => notifier.updateVerificationIdAndPhone( verificationId: widget.verificationId, phone: widget.phoneNumber, + code: widget.countryCode, ), ); super.initState(); @@ -113,7 +114,9 @@ class _PhoneVerificationScreenState const SizedBox( height: 16, ), - PhoneVerificationResendCodeView(countryCode: widget.countryCode, phoneNumber: widget.phoneNumber), + PhoneVerificationResendCodeView( + countryCode: widget.countryCode, + phoneNumber: widget.phoneNumber), ], ), ); diff --git a/khelo/lib/ui/flow/sign_in/phone_verification/phone_verification_view_model.dart b/khelo/lib/ui/flow/sign_in/phone_verification/phone_verification_view_model.dart index c1b592c0..dbd4f45a 100644 --- a/khelo/lib/ui/flow/sign_in/phone_verification/phone_verification_view_model.dart +++ b/khelo/lib/ui/flow/sign_in/phone_verification/phone_verification_view_model.dart @@ -20,6 +20,7 @@ class PhoneVerificationViewNotifier final AuthService _authService; late Timer timer; late String phoneNumber; + late String countryCode; bool firstAutoVerificationComplete = false; @@ -56,9 +57,11 @@ class PhoneVerificationViewNotifier void updateVerificationIdAndPhone({ required String verificationId, required String phone, + required String code, }) { state = state.copyWith(verificationId: verificationId); phoneNumber = phone; + countryCode = code; } Future resendCode({required String countryCode, required String phone}) async { @@ -90,7 +93,7 @@ class PhoneVerificationViewNotifier state = state.copyWith(verifying: true, showErrorVerificationCodeText: false, actionError: null); try { - await _authService.verifyOTP("+91",phoneNumber,state.verificationId!, state.otp); + await _authService.verifyOTP(countryCode, phoneNumber, state.verificationId!, state.otp); state = state.copyWith(verifying: false, isVerificationComplete: true); } on AppError catch (e) { if (e.l10nCode == AppErrorL10nCodes.invalidVerificationCode) {