Skip to content

Commit

Permalink
fix running match stat not updated
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-sidhdhi-p committed Apr 30, 2024
1 parent c40d1ab commit 2b1b882
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 25 deletions.
47 changes: 25 additions & 22 deletions data/lib/service/match/match_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -221,26 +221,29 @@ class MatchService {
for (QueryDocumentSnapshot mainDoc in snapshot.docs) {
Map<String, dynamic> mainDocData =
mainDoc.data() as Map<String, dynamic>;
AddEditMatchRequest match = AddEditMatchRequest.fromJson(mainDocData);

List<MatchTeamModel> 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<MatchTeamModel> 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) {
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion khelo/lib/ui/flow/home/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
},
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class _PhoneVerificationScreenState
() => notifier.updateVerificationIdAndPhone(
verificationId: widget.verificationId,
phone: widget.phoneNumber,
code: widget.countryCode,
),
);
super.initState();
Expand Down Expand Up @@ -113,7 +114,9 @@ class _PhoneVerificationScreenState
const SizedBox(
height: 16,
),
PhoneVerificationResendCodeView(countryCode: widget.countryCode, phoneNumber: widget.phoneNumber),
PhoneVerificationResendCodeView(
countryCode: widget.countryCode,
phoneNumber: widget.phoneNumber),
],
),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class PhoneVerificationViewNotifier
final AuthService _authService;
late Timer timer;
late String phoneNumber;
late String countryCode;

bool firstAutoVerificationComplete = false;

Expand Down Expand Up @@ -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<void> resendCode({required String countryCode, required String phone}) async {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 2b1b882

Please sign in to comment.