Upgrading links sentence; multi-seed radio

This commit is contained in:
James Barnsley
2019-10-05 09:10:34 +13:00
parent d1d2ee5ca3
commit 96d68c0ae0
29 changed files with 502 additions and 552 deletions

View File

@ -5,7 +5,7 @@ import { bindActionCreators } from 'redux';
import InputRange from 'react-input-range';
import Header from '../../components/Header';
import ArtistSentence from '../../components/ArtistSentence';
import LinksSentence from '../../components/LinksSentence';
import ArtistGrid from '../../components/ArtistGrid';
import AlbumGrid from '../../components/AlbumGrid';
import TrackList from '../../components/TrackList';
@ -23,7 +23,7 @@ import * as uiActions from '../../services/ui/actions';
import * as mopidyActions from '../../services/mopidy/actions';
import * as spotifyActions from '../../services/spotify/actions';
class Discover extends React.Component {
class Discover extends React.Component {
constructor(props) {
super(props);
@ -157,14 +157,14 @@ class Discover extends React.Component {
}
}
componentWillReceiveProps(newProps, newState) {
componentWillReceiveProps(newProps, newState) {
// New seeds via URL
if (newProps.match.params.seeds != this.props.match.params.seeds) {
this.handleURLSeeds(newProps.match.params.seeds);
}
}
handleContextMenu(e) {
handleContextMenu(e) {
var uri = 'iris:discover';
if (this.state.seeds) {
uri += ':';
@ -195,14 +195,14 @@ class Discover extends React.Component {
this.props.uiActions.showContextMenu(data);
}
handleURLSeeds(seeds_string = this.props.match.params.seeds) {
handleURLSeeds(seeds_string = this.props.match.params.seeds) {
// Rejoin if we've had to uri-encode these as strings
// We'd need to do this if our URL has been encoded so the whole URL can become
// it's own URI (eg iris:discover:spotify_artist_1234) where we can't use ":"
const seeds = seeds_string.split('_').join(':').split(',');
for (let i = 0; i < seeds.length; i++) {
switch (helpers.uriType(seeds[i])) {
switch (helpers.uriType(seeds[i])) {
case 'artist':
this.props.spotifyActions.getArtist(seeds[i]);
break;
@ -263,7 +263,7 @@ class Discover extends React.Component {
for (let i = 0; i < this.state.seeds.length; i++) {
const uri = this.state.seeds[i];
switch (helpers.uriType(uri)) {
switch (helpers.uriType(uri)) {
case 'track':
if (typeof (this.props.tracks[uri]) !== 'undefined') {
seeds_objects.push(this.props.tracks[uri]);
@ -345,7 +345,7 @@ class Discover extends React.Component {
const addable_tunabilities = [];
const enabled_tunabilities = [];
for (const key in this.state.tunabilities) {
if (this.state.tunabilities.hasOwnProperty(key)) {
if (this.state.tunabilities.hasOwnProperty(key)) {
const tunability = {
...this.state.tunabilities[key],
@ -380,7 +380,7 @@ class Discover extends React.Component {
minValue={tunability.min}
maxValue={tunability.max}
value={tunability.value}
onChange={(value) => this.setTunability(tunability.name, value)}
onChange={(value) => this.setTunability(tunability.name, value)}
/>
</div>
</div>
@ -390,7 +390,7 @@ class Discover extends React.Component {
);
}
renderResults() {
renderResults() {
// Results not in
if (!this.props.recommendations || this.props.recommendations.albums_uris === undefined || this.props.recommendations.artists_uris === undefined) {
return <div className="content-wrapper recommendations-results" />;
@ -479,7 +479,7 @@ class Discover extends React.Component {
const is_loading = helpers.isLoading(this.props.load_queue, ['spotify_recommendations']);
const addable_tunabilities = [];
for (const key in this.state.tunabilities) {
if (this.state.tunabilities.hasOwnProperty(key)) {
if (this.state.tunabilities.hasOwnProperty(key)) {
const tunability = {
...this.state.tunabilities[key],
@ -516,7 +516,7 @@ class Discover extends React.Component {
<AddSeedField onSelect={(e, uri) => this.handleSelect(e, uri)} />
<DropdownField className="add-properties" name="Properties" options={addable_tunabilities} no_status_icon button="default" handleChange={(val) => { this.toggleTunability(val); }} />
<span className={`submit button button--primary button--large${is_loading ? ' button--working' : ''}`} onClick={(e) => this.getRecommendations()}>
<Icon name="explore" />
<Icon name="explore" />
&nbsp;
Find recommendations
</span>
@ -551,4 +551,4 @@ const mapDispatchToProps = (dispatch) => ({
spotifyActions: bindActionCreators(spotifyActions, dispatch),
});
export default connect(mapStateToProps, mapDispatchToProps)(Discover);
export default connect(mapStateToProps, mapDispatchToProps)(Discover);