Reflect clear-all-checklists in the open slide editor
The editor subtree is keyed on the deck revision and only re-reads its slide when that revision changes. clearAllChecklists mutated the deck without bumping the revision, so the currently selected slide's editor kept showing its cached (still-checked) checkboxes even though the slide preview updated. Add a bumpRevision flag to _mutate and use it for the deck-wide clear so the editor remounts and reflects the cleared state. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
3ca94771b9
commit
9fe5771d44
2 changed files with 18 additions and 2 deletions
|
|
@ -346,7 +346,12 @@ class DeckNotifier extends StateNotifier<DeckState> {
|
||||||
slides.add(s);
|
slides.add(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (changed) _mutate(deck.copyWith(slides: slides));
|
// Bump de revisie zodat de editor van de geselecteerde slide remount en de
|
||||||
|
// uitgevinkte checkboxen ook in het invoerpaneel toont (niet alleen in de
|
||||||
|
// slidepreview).
|
||||||
|
if (changed) {
|
||||||
|
_mutate(deck.copyWith(slides: slides), bumpRevision: true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Zoeken & vervangen ─────────────────────────────────────────────────────
|
// ── Zoeken & vervangen ─────────────────────────────────────────────────────
|
||||||
|
|
@ -553,7 +558,14 @@ class DeckNotifier extends StateNotifier<DeckState> {
|
||||||
/// binnen [_coalesceWindow] valt, wordt geen nieuwe ongedaan-stap aangemaakt
|
/// binnen [_coalesceWindow] valt, wordt geen nieuwe ongedaan-stap aangemaakt
|
||||||
/// (zodat typen niet per teken een aparte stap oplevert). Een [coalesceKey]
|
/// (zodat typen niet per teken een aparte stap oplevert). Een [coalesceKey]
|
||||||
/// van null markeert een losse, discrete stap.
|
/// van null markeert een losse, discrete stap.
|
||||||
void _mutate(Deck deck, {String? coalesceKey}) {
|
///
|
||||||
|
/// Wanneer [bumpRevision] waar is, wordt de inhouds-revisie opgehoogd. Dat
|
||||||
|
/// dwingt de editor-subtree (die op `revision` is gesleuteld) om te remounten
|
||||||
|
/// en zijn velden opnieuw uit de slide te laden. Nodig bij deck-brede
|
||||||
|
/// bewerkingen die de huidige slide aanpassen zonder dat de editor zelf de
|
||||||
|
/// bron van de wijziging was (anders blijft de editor de oude, gecachte
|
||||||
|
/// waarden tonen).
|
||||||
|
void _mutate(Deck deck, {String? coalesceKey, bool bumpRevision = false}) {
|
||||||
final previous = state.deck;
|
final previous = state.deck;
|
||||||
if (previous != null) {
|
if (previous != null) {
|
||||||
final now = DateTime.now();
|
final now = DateTime.now();
|
||||||
|
|
@ -576,6 +588,7 @@ class DeckNotifier extends StateNotifier<DeckState> {
|
||||||
isDirty: true,
|
isDirty: true,
|
||||||
canUndo: _undoStack.isNotEmpty,
|
canUndo: _undoStack.isNotEmpty,
|
||||||
canRedo: false,
|
canRedo: false,
|
||||||
|
revision: bumpRevision ? state.revision + 1 : null,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -151,6 +151,7 @@ void main() {
|
||||||
n.loadDeck(n.state.deck!.copyWith(slides: [s1, s2]));
|
n.loadDeck(n.state.deck!.copyWith(slides: [s1, s2]));
|
||||||
|
|
||||||
expect(n.checkedChecklistCount, 4);
|
expect(n.checkedChecklistCount, 4);
|
||||||
|
final revisionBefore = n.state.revision;
|
||||||
|
|
||||||
n.clearAllChecklists();
|
n.clearAllChecklists();
|
||||||
|
|
||||||
|
|
@ -159,6 +160,8 @@ void main() {
|
||||||
expect(out[0].bullets, ['[ ] Klaar', '\t[ ] Subklaar', '[ ] Open']);
|
expect(out[0].bullets, ['[ ] Klaar', '\t[ ] Subklaar', '[ ] Open']);
|
||||||
expect(out[1].bullets, ['[ ] Eerste kolom']);
|
expect(out[1].bullets, ['[ ] Eerste kolom']);
|
||||||
expect(out[1].bullets2, ['[ ] Tweede kolom', '[ ] Nog open']);
|
expect(out[1].bullets2, ['[ ] Tweede kolom', '[ ] Nog open']);
|
||||||
|
// Revision bumps so the open slide editor remounts and reflects the change.
|
||||||
|
expect(n.state.revision, greaterThan(revisionBefore));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('clearAllChecklists is a no-op when nothing is checked', () {
|
test('clearAllChecklists is a no-op when nothing is checked', () {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue