@ -31,6 +31,8 @@ class Queue extends Component {
constructor ( props , context ) {
constructor ( props , context ) {
super ( props , context ) ;
super ( props , context ) ;
this . _shouldBlockRefresh = false ;
this . state = {
this . state = {
allSelected : false ,
allSelected : false ,
allUnselected : false ,
allUnselected : false ,
@ -42,6 +44,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 ) {
componentDidUpdate ( prevProps ) {
const {
const {
items ,
items ,
@ -84,6 +98,10 @@ class Queue extends Component {
//
//
// Listeners
// Listeners
onQueueRowModalOpenOrClose = ( isOpen ) => {
this . _shouldBlockRefresh = isOpen ;
}
onSelectAllChange = ( { value } ) => {
onSelectAllChange = ( { value } ) => {
this . setState ( selectAll ( this . state . selectedState , value ) ) ;
this . setState ( selectAll ( this . state . selectedState , value ) ) ;
}
}
@ -99,16 +117,19 @@ class Queue extends Component {
}
}
onRemoveSelectedPress = ( ) => {
onRemoveSelectedPress = ( ) => {
this . _shouldBlockRefresh = true ;
this . setState ( { isConfirmRemoveModalOpen : true } ) ;
this . setState ( { isConfirmRemoveModalOpen : true } ) ;
}
}
onRemoveSelectedConfirmed = ( payload ) => {
onRemoveSelectedConfirmed = ( payload ) => {
this . props . onRemoveSelectedPress ( { ids : this . getSelectedIds ( ) , ... payload } ) ;
this . props . onRemoveSelectedPress ( { ids : this . getSelectedIds ( ) , ... payload } ) ;
this . setState ( { isConfirmRemoveModalOpen : false } ) ;
this . setState ( { isConfirmRemoveModalOpen : false } ) ;
this . _shouldBlockRefresh = false ;
}
}
onConfirmRemoveModalClose = ( ) => {
onConfirmRemoveModalClose = ( ) => {
this . setState ( { isConfirmRemoveModalOpen : false } ) ;
this . setState ( { isConfirmRemoveModalOpen : false } ) ;
this . _shouldBlockRefresh = false ;
}
}
//
//
@ -209,7 +230,7 @@ class Queue extends Component {
}
}
{
{
is Populated && ! hasError && ! items . length &&
is All Populated && ! hasError && ! items . length &&
< div >
< div >
Queue is empty
Queue is empty
< / d i v >
< / d i v >
@ -238,6 +259,7 @@ class Queue extends Component {
columns = { columns }
columns = { columns }
{ ... item }
{ ... item }
onSelectedChange = { this . onSelectedChange }
onSelectedChange = { this . onSelectedChange }
onQueueRowModalOpenOrClose = { this . onQueueRowModalOpenOrClose }
/ >
/ >
) ;
) ;
} )
} )