2017-02-10 09:06:41 +13:00
|
|
|
|
2019-09-05 15:36:11 +12:00
|
|
|
import React from 'react';
|
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
import { bindActionCreators } from 'redux';
|
|
|
|
|
import TrackList from '../components/TrackList';
|
|
|
|
|
import Header from '../components/Header';
|
|
|
|
|
import Icon from '../components/Icon';
|
|
|
|
|
import * as uiActions from '../services/ui/actions';
|
|
|
|
|
import * as pusherActions from '../services/pusher/actions';
|
|
|
|
|
import * as spotifyActions from '../services/spotify/actions';
|
|
|
|
|
import * as mopidyActions from '../services/mopidy/actions';
|
2020-07-17 22:12:47 +12:00
|
|
|
import { i18n, I18n } from '../locale';
|
2020-08-16 20:00:10 +12:00
|
|
|
import Button from '../components/Button';
|
2019-09-05 15:36:11 +12:00
|
|
|
|
2020-03-03 16:39:37 +13:00
|
|
|
class QueueHistory extends React.Component {
|
2019-09-05 15:36:11 +12:00
|
|
|
componentDidMount() {
|
2020-07-17 22:12:47 +12:00
|
|
|
const { uiActions: { setWindowTitle } } = this.props;
|
|
|
|
|
setWindowTitle(i18n('queue_history.title'));
|
2019-09-05 15:36:11 +12:00
|
|
|
this.loadHistory();
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-11 21:05:36 +12:00
|
|
|
loadHistory = () => {
|
2020-07-17 22:12:47 +12:00
|
|
|
const {
|
2020-08-11 21:05:36 +12:00
|
|
|
mopidyActions: {
|
|
|
|
|
getQueueHistory,
|
|
|
|
|
},
|
2020-07-17 22:12:47 +12:00
|
|
|
} = this.props;
|
|
|
|
|
|
2020-09-11 22:13:06 +12:00
|
|
|
console.log('get queue history');
|
|
|
|
|
|
2020-08-11 21:05:36 +12:00
|
|
|
getQueueHistory();
|
2019-09-05 15:36:11 +12:00
|
|
|
}
|
|
|
|
|
|
2020-07-17 22:12:47 +12:00
|
|
|
onBack = () => {
|
|
|
|
|
const { history: { push } } = this.props;
|
|
|
|
|
push('/queue');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render = () => {
|
|
|
|
|
const {
|
|
|
|
|
queue_history,
|
2020-09-11 22:13:06 +12:00
|
|
|
items,
|
2020-07-17 22:12:47 +12:00
|
|
|
uiActions,
|
|
|
|
|
} = this.props;
|
|
|
|
|
|
2019-09-05 15:36:11 +12:00
|
|
|
const options = (
|
2020-08-16 20:00:10 +12:00
|
|
|
<Button
|
|
|
|
|
onClick={this.onBack}
|
|
|
|
|
noHover
|
|
|
|
|
tracking={{ category: 'QueueHistory', action: 'Back' }}
|
|
|
|
|
>
|
2020-07-17 22:12:47 +12:00
|
|
|
<I18n path="actions.back">
|
|
|
|
|
<Icon name="keyboard_backspace" />
|
|
|
|
|
{' '}
|
|
|
|
|
</I18n>
|
2020-08-16 20:00:10 +12:00
|
|
|
</Button>
|
2019-09-05 15:36:11 +12:00
|
|
|
);
|
|
|
|
|
|
2020-09-11 22:13:06 +12:00
|
|
|
if (!queue_history) return null;
|
|
|
|
|
|
2020-07-17 22:12:47 +12:00
|
|
|
const tracks = queue_history.map((item) => ({
|
|
|
|
|
...item,
|
2020-09-11 22:13:06 +12:00
|
|
|
...(items[item.uri] || {}),
|
2020-07-17 22:12:47 +12:00
|
|
|
}));
|
2019-09-05 15:36:11 +12:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="view queue-history-view">
|
2020-07-17 22:12:47 +12:00
|
|
|
<Header options={options} uiActions={uiActions}>
|
|
|
|
|
<I18n path="queue_history.title">
|
|
|
|
|
<Icon name="play_arrow" type="material" />
|
|
|
|
|
</I18n>
|
2019-09-05 15:36:11 +12:00
|
|
|
</Header>
|
|
|
|
|
<section className="content-wrapper">
|
|
|
|
|
<TrackList
|
2020-04-08 09:15:45 +12:00
|
|
|
uri="iris:queue-history"
|
2019-09-05 15:36:11 +12:00
|
|
|
className="queue-history-track-list"
|
|
|
|
|
track_context="history"
|
|
|
|
|
tracks={tracks}
|
2020-03-03 16:39:37 +13:00
|
|
|
show_source_icon
|
2019-09-05 15:36:11 +12:00
|
|
|
/>
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
2017-02-10 09:06:41 +13:00
|
|
|
}
|
|
|
|
|
|
2020-07-17 22:12:47 +12:00
|
|
|
const mapStateToProps = (state) => ({
|
2020-09-11 22:13:06 +12:00
|
|
|
items: state.core.items,
|
|
|
|
|
queue_history: state.mopidy.queue_history,
|
2019-09-05 15:36:11 +12:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const mapDispatchToProps = (dispatch) => ({
|
|
|
|
|
uiActions: bindActionCreators(uiActions, dispatch),
|
|
|
|
|
pusherActions: bindActionCreators(pusherActions, dispatch),
|
|
|
|
|
spotifyActions: bindActionCreators(spotifyActions, dispatch),
|
|
|
|
|
mopidyActions: bindActionCreators(mopidyActions, dispatch),
|
|
|
|
|
});
|
|
|
|
|
|
2020-03-03 16:39:37 +13:00
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(QueueHistory);
|