Skip to content

Commit 3976392

Browse files
committed
feat: count fsrs as streak
Signed-off-by: OctagonalStar <[email protected]>
1 parent b7db4b2 commit 3976392

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
- 优化了网页端字体加载逻辑
1515
- 重构了Config数据结构 [#27](https://github.com/OctagonalStar/arabic_learning/issues/27)
1616
- 重构了软件运行时数据结构 [#16](https://github.com/OctagonalStar/arabic_learning/issues/16)
17+
- 优化连胜逻辑: FSRS复习也计算为连胜
1718

1819
### Fix
1920

lib/pages/learning_page.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ Future<void> shiftToStudy(BuildContext context, int studyType) async {
160160
if(!context.mounted) return;
161161
context.read<Global>().uiLogger.info("返回完成情况: $finished");
162162
if(finished??false) {
163-
context.read<Global>().saveLearningProgress(words);
163+
context.read<Global>().updateLearningStreak();
164164
}
165165
}
166166

lib/sub_pages_builder/learning_pages/fsrs_pages.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ class _FSRSReviewCardPage extends State<FSRSReviewCardPage> {
269269
});
270270
if(correct == value) {
271271
widget.fsrs.reviewCard(widget.wordID, DateTime.now().difference(start).inMilliseconds, true);
272+
context.read<Global>().updateLearningStreak();
272273
return true;
273274
} else {
274275
widget.fsrs.reviewCard(widget.wordID, DateTime.now().difference(start).inMilliseconds, false);

lib/vars/global.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,11 +270,11 @@ class Global with ChangeNotifier {
270270
notifyListeners();
271271
}
272272

273-
void saveLearningProgress(List<WordItem> words){
274-
logger.info("保存学习进度中");
275-
// 以 2025/11/1 为基准计算天数(因为这个bug是这天修的:} )
273+
void updateLearningStreak(){
276274
final int nowDate = DateTime.now().difference(DateTime(2025, 11, 1)).inDays;
277275
if (nowDate == globalConfig.learning.lastDate) return;
276+
logger.info("保存学习进度中");
277+
// 以 2025/11/1 为基准计算天数(因为这个bug是这天修的:} )
278278
if (nowDate - globalConfig.learning.lastDate > 1) {
279279
globalConfig = globalConfig.copyWith(learning: globalConfig.learning.copyWith(startDate: nowDate));
280280
}

0 commit comments

Comments
 (0)