fix(study): cramming again after turning front and back

A session begun anew (turned to the other side, its settings changed, or
tried again) kept the cards it had crammed before, so a cram of a few
cards turned round said at once there was nothing to study. It now
crams every card again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
Tizian 「ティツィアーン」 2026-10-13 20:43:16 +02:00
commit cc777d6b06
Signed by: raisondetredev
GPG key ID: 07F6FCF405488B64
2 changed files with 30 additions and 0 deletions

View file

@ -183,6 +183,9 @@ class StudySessionBloc(
_learnAnyway = false; _learnAnyway = false;
_given.clear(); _given.clear();
_done.clear(); _done.clear();
// Cramming begins again with every card: turned to the other side, or
// with other settings, those crammed before are new to this session.
_crammed.clear();
return _startRound(emit); return _startRound(emit);
} }

View file

@ -912,6 +912,33 @@ void main() {
}); });
}); });
test('turning front and back crams every card again, the other way '
'round (it said there was nothing to study)', () async {
await cards.create('japanese', card('猫'));
await cards.create('japanese', card('犬'));
await study(const StudyOptions(mode: LearnMode.cram));
await withClock(Clock(() => now), () async {
final bloc = session();
addTearDown(bloc.close);
expect((await showing(bloc, '猫')).asksBack, isFalse);
bloc.add(const StudySessionEventBackFirstToggled());
final turned = await until(
bloc,
(s) =>
(s is StudySessionStateShowing && s.asksBack) ||
s is StudySessionStateNothing,
);
expect(turned, isA<StudySessionStateShowing>());
expect(
(turned as StudySessionStateShowing).card.content.front,
text('猫'),
);
});
});
test('newest first takes the studyset backwards', () async { test('newest first takes the studyset backwards', () async {
await cards.create('japanese', card('猫')); await cards.create('japanese', card('猫'));
await cards.create('japanese', card('犬')); await cards.create('japanese', card('犬'));