Skip to content

fix: 현재 스트릭 오류 수정 #80

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 27, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion lib/features/home/bloc/home_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:meta/meta.dart';
import 'package:shared_preferences_repository/shared_preferences_repository.dart';
import 'package:solved_api/solved_api.dart';
import 'package:timezone/timezone.dart' as tz;
import 'package:user_repository/user_repository.dart';

part "home_event.dart";
Expand Down Expand Up @@ -51,7 +52,22 @@ class HomeBloc extends Bloc<HomeEvent, HomeState> {
final badges = await _userRepository.getBadges(_handle);
final streak = await _userRepository.getStreak(_handle, "default");

late bool solvedToday = streak.currentStreak > 0;
streak.grass.sort((a, b) {
if (a.year != b.year) {
return a.year.compareTo(b.year);
} else if (a.month != b.month) {
return a.month.compareTo(b.month);
} else {
return a.day.compareTo(b.day);
}
});

tz.TZDateTime? today =
tz.TZDateTime.now(tz.UTC).add(const Duration(hours: 3));

late bool solvedToday = today.year == streak.grass.last.year &&
today.month == streak.grass.last.month &&
today.day == streak.grass.last.day;

final tagRatings = await _userRepository.getTagRatings(_handle);
final problemStats = await _userRepository.getProblemStats(_handle);
Expand Down