Skip to content

Commit

Permalink
Reset the kits of the previous collection before it is swapped. Updat…
Browse files Browse the repository at this point in the history
…e doc regarding currentCollectionProperty links. #141
  • Loading branch information
Denz1994 committed Feb 10, 2020
1 parent 2166beb commit fcf880d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions js/common/view/BAMScreenView.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ define( require => {
if ( previousCollection ) {
previousCollection.kits.forEach( kit => {

// Reset the kit before managing its listeners
kit.reset();

// Removed previous listeners related to metadataLayer create and deletion.
kit.addedMoleculeEmitter.removeListener( this.addedEmitterListeners[ kit.id ] );
kit.removedMoleculeEmitter.removeListener( this.removedEmitterListeners[ kit.id ] );
Expand Down
4 changes: 4 additions & 0 deletions js/common/view/CollectionPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ define( require => {
} ),
maxWidth: BAMConstants.TEXT_MAX_WIDTH
} );

// Manages changing the label of the current collection
kitCollectionList.currentCollectionProperty.link( () => {
currentCollectionText.text = StringUtils.fillIn( collectionPatternString, {
number: kitCollectionList.currentIndex + BuildAMoleculeQueryParameters.skipLevels
Expand All @@ -93,6 +95,7 @@ define( require => {
}
} );

// Update the arrows that indicate the next/previous collection
const updateSwitcher = () => {
collectionSwitcher.hasNextProperty.value = kitCollectionList.hasNextCollection();
collectionSwitcher.hasPreviousProperty.value = kitCollectionList.hasPreviousCollection();
Expand Down Expand Up @@ -127,6 +130,7 @@ define( require => {
// use the current collection
this.useCollection( kitCollectionList.currentCollectionProperty.value );

// As the current collection changes, use that new collection
kitCollectionList.currentCollectionProperty.link( newCollection => {
this.useCollection( newCollection );
} );
Expand Down

0 comments on commit fcf880d

Please sign in to comment.