Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/actions/entropy.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@
if (!entropy.loaded) return;

if (arg === nucleotide_gene) {
if (entropy.selectedCds === nucleotide_gene) {
return
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you've highlighted a nucleotide bar (in the entropy panel) and click "reset layout" the bar will no longer be highlighted because now action.selectedPositions = []; will be hit below.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simply dropping action.selectedPositions = [] doesn't work, I think because zoom bounds are tightly coupled with selected positions here:

if (this.selectedPositions?.length) {
const posMin = Math.min(...this.selectedPositions);
const posMax = Math.max(...this.selectedPositions);
/* If we already have coordinates which are not the default, and the new
positions are within the coordinates, then don't change zoom at all */
if (
this.zoomCoordinates &&
(this.zoomCoordinates[0]!==domain[0] || this.zoomCoordinates[1]!==domain[1]) &&
posMin>this.zoomCoordinates[0] && posMax<this.zoomCoordinates[1]
) {
return;
}
let desiredSurroundingSpace = Math.floor(domain[1] * 0.05); // 5%
if (desiredSurroundingSpace>1000) desiredSurroundingSpace=1000; // up to a max of 1kb
this.zoomCoordinates = [posMin - desiredSurroundingSpace, posMax + desiredSurroundingSpace];

// FIXME: these new values aren't reflected in UNSAFE_componentWillReceiveProps
action.zoomMin = 0;
action.zoomMax = entropy.genomeMap[0].range[1];

action.selectedCds = arg;
action.selectedPositions = [];
} else if (typeof arg === 'string') {
Expand Down Expand Up @@ -104,9 +105,13 @@
action.bars = data;
action.maxYVal = maxYVal;
} else if (isEqual(action.selectedPositions, entropy.selectedPositions)) {
return;
// FIXME: need to dispatch with zoomMin/zoomMax change, this will do for testing purposes
// return;
}

console.log(`[changeEntropyCdsSelection] dispatch actions:`)

Check warning on line 112 in src/actions/entropy.js

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement
console.log(action)

Check warning on line 113 in src/actions/entropy.js

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement

dispatch(action);
};

Expand Down
2 changes: 2 additions & 0 deletions src/components/entropy/entropyD3.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
zoomMax = undefined,
zoomMin = undefined
}) {
console.log(`[update] selectedCds: ${selectedCds} selectedPositions: ${selectedPositions} zoomMin: ${zoomMin} zoomMax: ${zoomMax}`)

Check warning on line 60 in src/components/entropy/entropyD3.js

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement
if (selectedCds) {
this.selectedCds = selectedCds;
this._setUpZoomBrushWrapping()
Expand Down Expand Up @@ -119,6 +120,7 @@
* - update
*/
EntropyChart.prototype._setZoomCoordinates = function _setZoomCoordinates(overrideMin, overrideMax, cdsChanged) {
console.log(`[_setZoomCoordinates] overrideMin: ${overrideMin} overrideMax: ${overrideMax} cdsChanged: ${cdsChanged}`)

Check warning on line 123 in src/components/entropy/entropyD3.js

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement

if (cdsChanged && this.zoomCoordinates) {
this.zoomCoordinates = undefined;
Expand Down
18 changes: 9 additions & 9 deletions src/components/entropy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@

resetLayout(styles) {
if (this.props.narrativeMode || !this.state.chart) return null;
const viewingGenome = this.props.selectedCds===nucleotide_gene;
/**
* The intention for this button is to be inactive when viewing the genome &
* fully zoomed out, however zoom actions do not trigger redux state changes
Expand All @@ -142,14 +141,13 @@
key={1}
style={tabGroupMember}
onClick={() => {
if (viewingGenome) {
this.state.chart.update({
zoomMin: this.state.chart.zoomBounds[0],
zoomMax: this.state.chart.zoomBounds[1],
})
} else {
this.props.dispatch(changeEntropyCdsSelection(nucleotide_gene));
}
// if (this.props.selectedCds === nucleotide_gene) {
// this.state.chart.update({
// zoomMin: this.state.chart.zoomBounds[0],
// zoomMax: this.state.chart.zoomBounds[1],
// })
// }
this.props.dispatch(changeEntropyCdsSelection(nucleotide_gene));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this change (and the earlier change), the following just above this line becomes unnecessary and can be removed:

            if (viewingGenome) {
              this.state.chart.update({
                zoomMin: this.state.chart.zoomBounds[0],
                zoomMax: this.state.chart.zoomBounds[1],
              })
            }

This is because we end up running update({selectedPositions: []}) which runs

    if (selectedCds || selectedPositions !== undefined) {
      this._setZoomCoordinates(zoomMin, zoomMax, !!selectedCds);
    }

so we'll always reset the coordinates to show the entire nuc span.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's still used for when no CDS or position is selected, when the min/max sliders are adjusted. I think the update can happen elsewhere though. Started with 1f40cd0 but haven't gotten it fully working.

}}
>
<span style={styles.switchTitle}> {'RESET LAYOUT'} </span>
Expand Down Expand Up @@ -221,6 +219,8 @@
}
}
UNSAFE_componentWillReceiveProps(nextProps) {
console.log(`[UNSAFE_componentWillReceiveProps] nextProps:`)

Check warning on line 222 in src/components/entropy/index.js

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement
console.log(nextProps)

Check warning on line 223 in src/components/entropy/index.js

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement
if (!nextProps.loaded) {
this.setState({chart: false});
}
Expand Down
Loading