Skip to content

Commit

Permalink
Fix crash on deleting queue items
Browse files Browse the repository at this point in the history
  • Loading branch information
nukeop committed Oct 1, 2019
1 parent 81de3d1 commit e0b9e35
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 13 deletions.
4 changes: 2 additions & 2 deletions packages/app/app/components/PlayQueue/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ class PlayQueue extends React.Component {
<QueueItem
index={i}
track={el}
loading={el.loading}
current={this.props.currentSong === i}
isLoading={el.loading}
isCurrent={this.props.currentSong === i}
defaultMusicSource={this.props.plugins.defaultMusicSource}
selectSong={this.props.actions.selectSong}
removeFromQueue={this.props.actions.removeFromQueue}
Expand Down
21 changes: 14 additions & 7 deletions packages/ui/lib/components/QueueItem/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React from 'react';
import PropTypes from 'prop-types';
import cx from 'classnames';
import { Icon } from 'semantic-ui-react';
import { compose, withHandlers } from 'recompose';

import Loader from '../Loader';
import common from '../../common.scss';
Expand All @@ -10,11 +12,11 @@ const QueueItem = props => {
let {
isLoading,
isCurrent,
index,
track,
duration,
selectSong,
removeFromQueue

handleRemoveFromQueue,
handleSelectSong
} = props;

return (
Expand All @@ -24,7 +26,7 @@ const QueueItem = props => {
styles.queue_item,
{[`${styles.current_song}`]: isCurrent}
)}
onDoubleClick={() => selectSong(index)}
onDoubleClick={handleSelectSong}
>
<div className={styles.thumbnail}>
{
Expand All @@ -35,9 +37,9 @@ const QueueItem = props => {

<div
className={styles.thumbnail_overlay}
onClick={() => removeFromQueue(index)}
onClick={handleRemoveFromQueue}
>
<i className='bx bx-trash bx-sm' />
<Icon name='trash alternate outline' size='big' />
</div>
</div>

Expand Down Expand Up @@ -73,4 +75,9 @@ QueueItem.propTypes = {
removeFromQueue: PropTypes.func
};

export default QueueItem;
export default compose(
withHandlers({
handleRemoveFromQueue: ({removeFromQueue, track}) => () => removeFromQueue(track),
handleSelectSong: ({selectSong, index}) => () => selectSong(index)
})
)(QueueItem);
10 changes: 7 additions & 3 deletions packages/ui/lib/components/QueueItem/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
.queue_item {
@include transition;
@include roundCorners;

display: flex;
flex-flow: row;
flex: 0 0 auto;
Expand All @@ -28,7 +28,7 @@
@include center;
@include circle;
@include transition;

position: absolute;
display: flex;
top: 0;
Expand All @@ -43,12 +43,16 @@
&:hover {
opacity: 0.85;
}

i {
margin: 0;
}
}
}

.item_info_container {
@include ellipsis;

display: flex;
margin: 0.25em;
flex: 1 1 auto;
Expand Down
4 changes: 3 additions & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@
"classnames": "^2.2.6",
"prop-types": "^15.6.2",
"react": "^16.4.1",
"react-dom": "^16.4.1"
"react-dom": "^16.4.1",
"recompose": "^0.30.0",
"semantic-ui-react": "^0.88.1"
},
"ava": {
"babel": {
Expand Down

0 comments on commit e0b9e35

Please sign in to comment.