Auto eslint fix

This commit is contained in:
James Barnsley
2019-09-05 15:36:11 +12:00
parent 4513a0d109
commit e4d53a2d35
126 changed files with 23283 additions and 23573 deletions

View File

@ -1,24 +1,24 @@
import React from "react";
import { connect } from "react-redux";
import { bindActionCreators } from "redux";
import React from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import Link from "../components/Link";
import Icon from "../components/Icon";
import Parallax from "../components/Parallax";
import TrackList from "../components/TrackList";
import Dater from "../components/Dater";
import ArtistSentence from "../components/ArtistSentence";
import Thumbnail from "../components/Thumbnail";
import Header from "../components/Header";
import URILink from "../components/URILink";
import LazyLoadListener from "../components/LazyLoadListener";
import Link from '../components/Link';
import Icon from '../components/Icon';
import Parallax from '../components/Parallax';
import TrackList from '../components/TrackList';
import Dater from '../components/Dater';
import ArtistSentence from '../components/ArtistSentence';
import Thumbnail from '../components/Thumbnail';
import Header from '../components/Header';
import URILink from '../components/URILink';
import LazyLoadListener from '../components/LazyLoadListener';
import * as helpers from "../helpers";
import * as coreActions from "../services/core/actions";
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";
import * as helpers from '../helpers';
import * as coreActions from '../services/core/actions';
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';
class Queue extends React.Component {
constructor(props) {
@ -26,22 +26,22 @@ class Queue extends React.Component {
this.state = {
limit: 50,
per_page: 50
per_page: 50,
};
}
componentWillMount() {
// Before we mount, restore any limit defined in our location state
var state = this.props.location.state ? this.props.location.state : {};
const state = this.props.location.state ? this.props.location.state : {};
if (state.limit) {
this.setState({
limit: state.limit
limit: state.limit,
});
}
}
componentDidMount() {
this.props.uiActions.setWindowTitle("Now playing");
this.props.uiActions.setWindowTitle('Now playing');
}
shouldComponentUpdate(nextProps) {
@ -54,13 +54,13 @@ class Queue extends React.Component {
if (added_from_uri && this.props.added_from_uri !== added_from_uri) {
const item_type = helpers.uriType(added_from_uri);
switch (item_type) {
case "album":
case 'album':
this.props.coreActions.loadAlbum(added_from_uri);
break;
case "artist":
case 'artist':
this.props.coreActions.loadArtist(added_from_uri);
break;
case "playlist":
case 'playlist':
this.props.coreActions.loadPlaylist(added_from_uri);
break;
}
@ -68,23 +68,22 @@ class Queue extends React.Component {
}
loadMore() {
var new_limit = this.state.limit + this.state.per_page;
const new_limit = this.state.limit + this.state.per_page;
this.setState({ limit: new_limit });
// Set our pagination to location state
var state =
this.props.location && this.props.location.state
? this.props.location.state
: {};
const state = this.props.location && this.props.location.state
? this.props.location.state
: {};
state.limit = new_limit;
this.props.history.replace({ state: state });
this.props.history.replace({ state });
}
removeTracks(track_indexes) {
var tlids = [];
for (var i = 0; i < track_indexes.length; i++) {
var track = this.props.queue_tracks[track_indexes[i]];
const tlids = [];
for (let i = 0; i < track_indexes.length; i++) {
const track = this.props.queue_tracks[track_indexes[i]];
if (track.tlid !== undefined) {
tlids.push(track.tlid);
}
@ -108,11 +107,15 @@ class Queue extends React.Component {
}
renderQueueStats() {
var total_time = 0;
const total_time = 0;
return (
<div className="queue-stats mid_grey-text">
<span>{this.props.current_tracklist.length} tracks</span>
<span>
{this.props.current_tracklist.length}
{' '}
tracks
</span>
&nbsp;&nbsp;|&nbsp;&nbsp;
{this.props.current_tracklist.length > 0 ? (
<Dater type="total-time" data={this.props.current_tracklist} />
@ -129,8 +132,8 @@ class Queue extends React.Component {
<div
className={`current-track__artwork ${
this.props.radio_enabled
? "current-track__artwork--radio-enabled"
: ""
? 'current-track__artwork--radio-enabled'
: ''
}`}
>
{this.props.radio_enabled ? (
@ -144,7 +147,7 @@ class Queue extends React.Component {
);
}
var uri = null;
let uri = null;
if (this.props.current_track.album && this.props.current_track.album.uri) {
uri = this.props.current_track.album.uri;
}
@ -152,8 +155,8 @@ class Queue extends React.Component {
<div
className={`current-track__artwork ${
this.props.radio_enabled
? "current-track__artwork--radio-enabled"
: ""
? 'current-track__artwork--radio-enabled'
: ''
}`}
>
<URILink type="album" uri={uri}>
@ -174,7 +177,7 @@ class Queue extends React.Component {
if (!added_from_uri) return null;
const item_type = helpers.uriType(added_from_uri);
const item_library = this.props[item_type + "s"];
const item_library = this.props[`${item_type}s`];
if (!item_library) return null;
const item = item_library[added_from_uri];
@ -190,11 +193,12 @@ class Queue extends React.Component {
<Thumbnail
images={item.images}
size="small"
circle={item_type == "artist"}
circle={item_type == 'artist'}
/>
</URILink>
<div className="current-track__added-from__text">
Playing from{" "}
Playing from
{' '}
<URILink type={item_type} uri={item.uri}>
{item.name}
</URILink>
@ -208,17 +212,17 @@ class Queue extends React.Component {
const total_queue_tracks = queue_tracks.length;
const tracks = queue_tracks.slice(0, this.state.limit);
var current_track_image = null;
let current_track_image = null;
if (current_track && this.props.current_track_uri) {
if (current_track.images !== undefined && current_track.images) {
current_track_image = current_track.images.large;
}
}
var options = (
const options = (
<span>
{this.props.spotify_enabled ? (
<Link className="button button--no-hover" to={"/queue/radio"}>
<Link className="button button--no-hover" to="/queue/radio">
<Icon name="radio" />
Radio
{this.props.radio && this.props.radio.enabled ? (
@ -226,13 +230,13 @@ class Queue extends React.Component {
) : null}
</Link>
) : null}
<Link className="button button--no-hover" to={"/queue/history"}>
<Link className="button button--no-hover" to="/queue/history">
<Icon name="history" />
History
</Link>
<a
className="button button--no-hover"
onClick={e => {
onClick={(e) => {
this.props.mopidyActions.clearTracklist();
this.props.uiActions.hideContextMenu();
}}
@ -240,7 +244,7 @@ class Queue extends React.Component {
<Icon name="delete_sweep" />
Clear
</a>
<Link className="button button--no-hover" to={"/queue/add-uri"}>
<Link className="button button--no-hover" to="/queue/add-uri">
<Icon name="playlist_add" />
Add URI
</Link>
@ -287,12 +291,10 @@ class Queue extends React.Component {
track_context="queue"
className="queue-track-list"
tracks={tracks}
removeTracks={track_indexes => this.removeTracks(track_indexes)}
playTracks={tracks => this.playTracks(tracks)}
playTrack={track => this.playTrack(track)}
reorderTracks={(indexes, index) =>
this.reorderTracks(indexes, index)
}
removeTracks={(track_indexes) => this.removeTracks(track_indexes)}
playTracks={(tracks) => this.playTracks(tracks)}
playTrack={(track) => this.playTrack(track)}
reorderTracks={(indexes, index) => this.reorderTracks(indexes, index)}
/>
</section>
@ -312,29 +314,27 @@ class Queue extends React.Component {
}
const mapStateToProps = (state, ownProps) => {
let current_track = state.core.current_track;
let queue_tracks = [];
let { current_track } = state.core;
const queue_tracks = [];
if (state.core.queue && state.core.tracks) {
for (let queue_track of state.core.queue) {
let track = Object.assign({}, queue_track);
for (const queue_track of state.core.queue) {
let track = { ...queue_track };
// If we have the track in our index, merge it in.
// We prioritise queue track over index track as queue has unique data, like which track
// is playing and tlids.
if (state.core.tracks.hasOwnProperty(track.uri)) {
track = Object.assign({}, state.core.tracks[track.uri], track, {
playing: current_track && current_track.tlid == track.tlid
});
track = { ...state.core.tracks[track.uri], ...track, playing: current_track && current_track.tlid == track.tlid };
}
// Now merge in our queue metadata
if (state.core.queue_metadata["tlid_" + track.tlid] !== undefined) {
track = Object.assign(
{},
track,
state.core.queue_metadata["tlid_" + track.tlid]
);
if (state.core.queue_metadata[`tlid_${track.tlid}`] !== undefined) {
track = {
...track,
...state.core.queue_metadata[`tlid_${track.tlid}`],
};
}
// Siphon off this track if it's a full representation of our current track (by tlid)
@ -351,31 +351,29 @@ const mapStateToProps = (state, ownProps) => {
theme: state.ui.theme,
spotify_enabled: state.spotify.enabled,
radio: state.core.radio,
radio_enabled: state.core.radio && state.core.radio.enabled ? true : false,
radio_enabled: !!(state.core.radio && state.core.radio.enabled),
artists: state.core.artists,
albums: state.core.albums,
playlists: state.core.playlists,
queue_tracks: queue_tracks,
queue_tracks,
current_track_uri: state.core.current_track_uri,
current_track: current_track,
current_track,
added_from_uri:
current_track && current_track.added_from
? current_track.added_from
: null
: null,
};
};
const mapDispatchToProps = dispatch => {
return {
coreActions: bindActionCreators(coreActions, dispatch),
uiActions: bindActionCreators(uiActions, dispatch),
pusherActions: bindActionCreators(pusherActions, dispatch),
spotifyActions: bindActionCreators(spotifyActions, dispatch),
mopidyActions: bindActionCreators(mopidyActions, dispatch)
};
};
const mapDispatchToProps = (dispatch) => ({
coreActions: bindActionCreators(coreActions, dispatch),
uiActions: bindActionCreators(uiActions, dispatch),
pusherActions: bindActionCreators(pusherActions, dispatch),
spotifyActions: bindActionCreators(spotifyActions, dispatch),
mopidyActions: bindActionCreators(mopidyActions, dispatch),
});
export default connect(
mapStateToProps,
mapDispatchToProps
mapDispatchToProps,
)(Queue);