Splitting out helpers into separate files
This commit is contained in:
@ -2,7 +2,6 @@
|
||||
import React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { bindActionCreators } from 'redux';
|
||||
|
||||
import Link from '../components/Link';
|
||||
import ErrorMessage from '../components/ErrorMessage';
|
||||
import Header from '../components/Header';
|
||||
@ -14,20 +13,21 @@ import SelectField from '../components/Fields/SelectField';
|
||||
import ContextMenuTrigger from '../components/ContextMenuTrigger';
|
||||
import Icon from '../components/Icon';
|
||||
import Loader from '../components/Loader';
|
||||
|
||||
import * as helpers from '../helpers';
|
||||
import * as coreActions from '../services/core/actions';
|
||||
import * as uiActions from '../services/ui/actions';
|
||||
import * as mopidyActions from '../services/mopidy/actions';
|
||||
import * as spotifyActions from '../services/spotify/actions';
|
||||
import * as lastfmActions from '../services/lastfm/actions';
|
||||
import * as geniusActions from '../services/genius/actions';
|
||||
import {
|
||||
isLoading,
|
||||
getFromUri,
|
||||
sourceIcon,
|
||||
uriSource,
|
||||
uriType,
|
||||
} from '../util/helpers';
|
||||
|
||||
class Track extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.props.coreActions.loadTrack(this.props.uri);
|
||||
|
||||
@ -155,7 +155,7 @@ class Track extends React.Component {
|
||||
}
|
||||
|
||||
renderLyrics() {
|
||||
if (helpers.isLoading(this.props.load_queue, ['genius_'])) {
|
||||
if (isLoading(this.props.load_queue, ['genius_'])) {
|
||||
return (
|
||||
<div className="lyrics">
|
||||
<Loader body loading />
|
||||
@ -179,7 +179,7 @@ class Track extends React.Component {
|
||||
}
|
||||
|
||||
render() {
|
||||
if (helpers.isLoading(this.props.load_queue, [`spotify_track/${helpers.getFromUri('trackid', this.props.uri)}`])) {
|
||||
if (isLoading(this.props.load_queue, [`spotify_track/${getFromUri('trackid', this.props.uri)}`])) {
|
||||
return <Loader body loading />
|
||||
}
|
||||
|
||||
@ -226,7 +226,7 @@ class Track extends React.Component {
|
||||
</h2>
|
||||
|
||||
<ul className="details">
|
||||
{!this.props.slim_mode ? <li className="source"><Icon type="fontawesome" name={helpers.sourceIcon(this.props.uri)} /></li> : null}
|
||||
{!this.props.slim_mode ? <li className="source"><Icon type="fontawesome" name={sourceIcon(this.props.uri)} /></li> : null}
|
||||
{track.date ? <li><Dater type="date" data={track.date} /></li> : null}
|
||||
{track.explicit ? <li><span className="flag flag--dark">EXPLICIT</span></li> : null}
|
||||
<li>
|
||||
@ -272,11 +272,11 @@ Want track lyrics? Authorize Genius under
|
||||
* @return String
|
||||
* */
|
||||
const rebuildUri = (uri) => {
|
||||
const rebuilt_uri = `${helpers.uriSource(uri)}:${helpers.uriType(uri)}:`;
|
||||
const rebuilt_uri = `${uriSource(uri)}:${uriType(uri)}:`;
|
||||
|
||||
// Escape unreserved characters (RFC 3986)
|
||||
// https://stackoverflow.com/questions/18251399/why-doesnt-encodeuricomponent-encode-single-quotes-apostrophes
|
||||
let id = helpers.getFromUri('trackid', uri);
|
||||
let id = getFromUri('trackid', uri);
|
||||
id = encodeURIComponent(id).replace(/[!'()*]/g, escape);
|
||||
|
||||
// Reinstate slashes for the Mopidy-Local structure
|
||||
|
||||
Reference in New Issue
Block a user