Skip to content

Commit

Permalink
Fix: Allow trickle on final branching article (fixes #203)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverfoster authored Oct 26, 2023
1 parent 9e31452 commit f07e0af
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions js/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,15 @@ class TrickleController extends Backbone.Controller {
* Returns true if the current page is locked by trickle
*/
get isTrickling() {
const isTrickling = Adapt.parentView.model.getAllDescendantModels().some(model => {
return model.get('_isAvailable') && model.get('_isTrickled') && model.get('_isLocked');
});
return isTrickling;
const currentDescendants = Adapt.parentView.model.getAllDescendantModels();
const isDescendantBlockedByTrickle = currentDescendants.some(model => model.get('_isAvailable') && model.get('_isTrickled') && model.get('_isLocked'));
if (isDescendantBlockedByTrickle) return true;
const TrickleModel = components.getModelClass('trickle-button');
const lastDescendant = currentDescendants[currentDescendants.length - 1];
const lastTrickleButton = currentDescendants.reverse().find(model => (model instanceof TrickleModel));
const isLastDescendantExpectingMoreChildren = (lastDescendant.get('_requireCompletionOf') === Number.POSITIVE_INFINITY && lastDescendant.get('_canRequestChild'));
const isLastTrickleButtonWaiting = (!lastTrickleButton?.get('_isComplete'));
return (isLastDescendantExpectingMoreChildren && isLastTrickleButtonWaiting);
}

/**
Expand Down

0 comments on commit f07e0af

Please sign in to comment.