From ceeea9f7c637e8bbb2cf6dd094831c36cd89e0f9 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sun, 24 Jan 2021 10:14:30 -0800 Subject: [PATCH] Fixed: Queue refresh closing manual import from queue if items change (cherry picked from commit f5d690aa7b703e6fc0cd7eeced177a28cfed4962) --- frontend/src/Activity/Queue/Queue.js | 24 +++++++++++++++++++++++- frontend/src/Activity/Queue/QueueRow.js | 18 ++++++++++++++++-- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/frontend/src/Activity/Queue/Queue.js b/frontend/src/Activity/Queue/Queue.js index 9a42efd19..bb974227e 100644 --- a/frontend/src/Activity/Queue/Queue.js +++ b/frontend/src/Activity/Queue/Queue.js @@ -32,6 +32,8 @@ class Queue extends Component { constructor(props, context) { super(props, context); + this._shouldBlockRefresh = false; + this.state = { allSelected: false, allUnselected: false, @@ -43,6 +45,18 @@ class Queue extends Component { }; } + shouldComponentUpdate(nextProps) { + if (!this._shouldBlockRefresh) { + return true; + } + + if (hasDifferentItems(this.props.items, nextProps.items)) { + return false; + } + + return true; + } + componentDidUpdate(prevProps) { const { items, @@ -85,6 +99,10 @@ class Queue extends Component { // // Listeners + onQueueRowModalOpenOrClose = (isOpen) => { + this._shouldBlockRefresh = isOpen; + } + onSelectAllChange = ({ value }) => { this.setState(selectAll(this.state.selectedState, value)); } @@ -100,16 +118,19 @@ class Queue extends Component { } onRemoveSelectedPress = () => { + this._shouldBlockRefresh = true; this.setState({ isConfirmRemoveModalOpen: true }); } onRemoveSelectedConfirmed = (payload) => { this.props.onRemoveSelectedPress({ ids: this.getSelectedIds(), ...payload }); this.setState({ isConfirmRemoveModalOpen: false }); + this._shouldBlockRefresh = false; } onConfirmRemoveModalClose = () => { this.setState({ isConfirmRemoveModalOpen: false }); + this._shouldBlockRefresh = false; } // @@ -208,7 +229,7 @@ class Queue extends Component { } { - isPopulated && !hasError && !items.length && + isAllPopulated && !hasError && !items.length &&
{translate('QueueIsEmpty')}
@@ -237,6 +258,7 @@ class Queue extends Component { columns={columns} {...item} onSelectedChange={this.onSelectedChange} + onQueueRowModalOpenOrClose={this.onQueueRowModalOpenOrClose} /> ); }) diff --git a/frontend/src/Activity/Queue/QueueRow.js b/frontend/src/Activity/Queue/QueueRow.js index 03570ac5c..97f13c51a 100644 --- a/frontend/src/Activity/Queue/QueueRow.js +++ b/frontend/src/Activity/Queue/QueueRow.js @@ -43,19 +43,32 @@ class QueueRow extends Component { } onRemoveQueueItemModalConfirmed = (blacklist) => { - this.props.onRemoveQueueItemPress(blacklist); + const { + onRemoveQueueItemPress, + onQueueRowModalOpenOrClose + } = this.props; + + onQueueRowModalOpenOrClose(false); + onRemoveQueueItemPress(blacklist); + this.setState({ isRemoveQueueItemModalOpen: false }); } onRemoveQueueItemModalClose = () => { + this.props.onQueueRowModalOpenOrClose(false); + this.setState({ isRemoveQueueItemModalOpen: false }); } onInteractiveImportPress = () => { + this.props.onQueueRowModalOpenOrClose(true); + this.setState({ isInteractiveImportModalOpen: true }); } onInteractiveImportModalClose = () => { + this.props.onQueueRowModalOpenOrClose(false); + this.setState({ isInteractiveImportModalOpen: false }); } @@ -359,7 +372,8 @@ QueueRow.propTypes = { columns: PropTypes.arrayOf(PropTypes.object).isRequired, onSelectedChange: PropTypes.func.isRequired, onGrabPress: PropTypes.func.isRequired, - onRemoveQueueItemPress: PropTypes.func.isRequired + onRemoveQueueItemPress: PropTypes.func.isRequired, + onQueueRowModalOpenOrClose: PropTypes.func.isRequired }; QueueRow.defaultProps = {