Merge branch 'develop' into master
This commit is contained in:
@ -9,7 +9,7 @@ import * as helpers from '../../helpers';
|
||||
import * as uiActions from '../../services/ui/actions';
|
||||
import * as spotifyActions from '../../services/spotify/actions';
|
||||
|
||||
class FollowButton extends React.Component {
|
||||
class FollowButton extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
@ -37,7 +37,7 @@ class FollowButton extends React.Component {
|
||||
} if (this.props.is_following === true) {
|
||||
return <button className={`${className} button--destructive`} onClick={(e) => this.remove()}>{this.props.removeText}</button>;
|
||||
}
|
||||
return <button className={`${className} button--default`} onClick={(e) => this.add()}>{this.props.addText}</button>;
|
||||
return <button className={`${className} button--default`} onClick={(e) => this.add()}>{this.props.addText}</button>;
|
||||
}
|
||||
}
|
||||
|
||||
@ -51,4 +51,4 @@ const mapDispatchToProps = (dispatch) => ({
|
||||
spotifyActions: bindActionCreators(spotifyActions, dispatch),
|
||||
});
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(FollowButton);
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(FollowButton);
|
||||
|
||||
@ -5,7 +5,7 @@ import { bindActionCreators } from 'redux';
|
||||
import * as helpers from '../../helpers';
|
||||
import * as uiActions from '../../services/ui/actions';
|
||||
|
||||
class SearchForm extends React.Component {
|
||||
class SearchForm extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
@ -36,7 +36,7 @@ class SearchForm extends React.Component {
|
||||
e.preventDefault();
|
||||
|
||||
// check for uri type matching
|
||||
switch (helpers.uriType(this.state.term)) {
|
||||
switch (helpers.uriType(this.state.term)) {
|
||||
case 'album':
|
||||
this.props.history.push(`/album/${encodeURIComponent(this.state.term)}`);
|
||||
break;
|
||||
@ -71,7 +71,7 @@ class SearchForm extends React.Component {
|
||||
onChange={(e) => this.setState({ term: e.target.value, pristine: false })}
|
||||
onBlur={(e) => this.handleBlur}
|
||||
onFocus={(e) => this.handleFocus}
|
||||
value={this.state.term}
|
||||
value={this.state.term}
|
||||
/>
|
||||
</label>
|
||||
</form>
|
||||
@ -83,4 +83,4 @@ const mapDispatchToProps = (dispatch) => ({
|
||||
uiActions: bindActionCreators(uiActions, dispatch),
|
||||
});
|
||||
|
||||
export default connect(mapDispatchToProps)(SearchForm);
|
||||
export default connect(mapDispatchToProps)(SearchForm);
|
||||
|
||||
@ -760,12 +760,14 @@ export function following(uri, method = 'GET') {
|
||||
endpoint = `playlists/${helpers.getFromUri('playlistid', uri)}/followers`;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
request(dispatch, getState, endpoint, method, data)
|
||||
.then(
|
||||
(response) => {
|
||||
if (response) {
|
||||
if (Array.isArray(response) && response.length > 0) {
|
||||
is_following = response[0];
|
||||
} else {
|
||||
is_following = is_following;
|
||||
@ -776,6 +778,14 @@ export function following(uri, method = 'GET') {
|
||||
key: uri,
|
||||
in_library: is_following,
|
||||
});
|
||||
|
||||
if (method !== 'GET') {
|
||||
dispatch(uiActions.createNotification(
|
||||
{
|
||||
message: is_following ? `Added ${asset_name} to library` : `Removed ${asset_name} from library`,
|
||||
}
|
||||
));
|
||||
}
|
||||
},
|
||||
(error) => {
|
||||
dispatch(coreActions.handleException(
|
||||
@ -1047,7 +1057,7 @@ export function getArtist(uri, full = false) {
|
||||
// Start with an empty object
|
||||
// As each requests completes, they'll add to this object
|
||||
const artist = {};
|
||||
|
||||
|
||||
// We need our artist, obviously
|
||||
const requests = [
|
||||
request(dispatch, getState, `artists/${helpers.getFromUri('artistid', uri)}`, 'GET', false, true)
|
||||
@ -1349,30 +1359,6 @@ export function getAlbum(uri) {
|
||||
};
|
||||
}
|
||||
|
||||
export function toggleAlbumInLibrary(uri, method) {
|
||||
if (method == 'PUT') var new_state = 1;
|
||||
if (method == 'DELETE') var new_state = 0;
|
||||
|
||||
return (dispatch, getState) => {
|
||||
request(dispatch, getState, `me/albums?ids=${helpers.getFromUri('albumid', uri)}`, method)
|
||||
.then(
|
||||
(response) => {
|
||||
dispatch({
|
||||
type: 'SPOTIFY_ALBUM_FOLLOWING',
|
||||
key: uri,
|
||||
data: new_state,
|
||||
});
|
||||
},
|
||||
(error) => {
|
||||
dispatch(coreActions.handleException(
|
||||
'Could not add/remove library album',
|
||||
error,
|
||||
));
|
||||
},
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* =============================================================== PLAYLIST(S) ==========
|
||||
@ -1710,30 +1696,6 @@ export function getAllPlaylistTracksProcessor(data) {
|
||||
};
|
||||
}
|
||||
|
||||
export function toggleFollowingPlaylist(uri, method) {
|
||||
if (method == 'PUT') var new_state = 1;
|
||||
if (method == 'DELETE') var new_state = 0;
|
||||
|
||||
return (dispatch, getState) => {
|
||||
request(dispatch, getState, `playlists/${helpers.getFromUri('playlistid', uri)}/followers`, method)
|
||||
.then(
|
||||
(response) => {
|
||||
dispatch({
|
||||
type: 'SPOTIFY_PLAYLIST_FOLLOWING_LOADED',
|
||||
key: uri,
|
||||
is_following: new_state,
|
||||
});
|
||||
},
|
||||
(error) => {
|
||||
dispatch(coreActions.handleException(
|
||||
'Could not add/remove library playlist',
|
||||
error,
|
||||
));
|
||||
},
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
export function addTracksToPlaylist(uri, tracks_uris) {
|
||||
return (dispatch, getState) => {
|
||||
request(dispatch, getState, `playlists/${helpers.getFromUri('playlistid', uri)}/tracks`, 'POST', { uris: tracks_uris })
|
||||
|
||||
@ -40,13 +40,20 @@ class Search extends React.Component {
|
||||
|
||||
// Listen for a query baked-in to the URL
|
||||
// This would be the case when we've clicked from a link elsewhere
|
||||
this.digestUri();
|
||||
this.digestUri({
|
||||
...this.props,
|
||||
term: decodeURIComponent(this.props.term),
|
||||
});
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
// Query changed
|
||||
if (nextProps.term !== this.props.term || nextProps.type !== this.props.type) {
|
||||
this.digestUri(nextProps);
|
||||
const { type, term } = this.props;
|
||||
const { type: nextType, term: nextTerm } = nextProps;
|
||||
if (nextType !== type || nextTerm !== term) {
|
||||
this.digestUri({
|
||||
type: nextType,
|
||||
term: nextTerm,
|
||||
});
|
||||
}
|
||||
|
||||
// Services came online
|
||||
@ -60,6 +67,8 @@ class Search extends React.Component {
|
||||
}
|
||||
|
||||
handleSubmit(term) {
|
||||
const encodedTerm = encodeURIComponent(term);
|
||||
|
||||
this.setState(
|
||||
{ term }, () => {
|
||||
// Unchanged term, so this is a forced re-search
|
||||
@ -68,7 +77,7 @@ class Search extends React.Component {
|
||||
if (this.props.term == term) {
|
||||
this.search();
|
||||
} else {
|
||||
this.props.history.push(`/search/${this.state.type}/${term}`);
|
||||
this.props.history.push(`/search/${this.state.type}/${encodedTerm}`);
|
||||
}
|
||||
},
|
||||
);
|
||||
@ -91,7 +100,7 @@ class Search extends React.Component {
|
||||
}
|
||||
|
||||
search(type = this.state.type, term = this.state.term, provider) {
|
||||
this.props.uiActions.setWindowTitle(`Search: ${term}`);
|
||||
this.props.uiActions.setWindowTitle(`Search: ${decodeURIComponent(term)}`);
|
||||
|
||||
if (type && term) {
|
||||
if (provider == 'mopidy' || (this.props.mopidy_connected && this.props.uri_schemes_search_enabled)) {
|
||||
@ -132,10 +141,11 @@ class Search extends React.Component {
|
||||
}
|
||||
|
||||
renderArtists(artists, spotify_search_enabled) {
|
||||
const encodedTerm = encodeURIComponent(this.state.term);
|
||||
return (
|
||||
<div>
|
||||
<h4>
|
||||
<URILink type="search" uri={`search:all:${this.state.term}`}>
|
||||
<URILink uri={`iris:search:all:${encodedTerm}`}>
|
||||
Search
|
||||
</URILink>
|
||||
<Icon type="fontawesome" name="angle-right" />
|
||||
@ -150,10 +160,11 @@ class Search extends React.Component {
|
||||
}
|
||||
|
||||
renderAlbums(albums, spotify_search_enabled) {
|
||||
const encodedTerm = encodeURIComponent(this.state.term);
|
||||
return (
|
||||
<div>
|
||||
<h4>
|
||||
<URILink type="search" uri={`search:all:${this.state.term}`}>
|
||||
<URILink uri={`iris:search:all:${encodedTerm}`}>
|
||||
{`Search `}
|
||||
</URILink>
|
||||
<Icon type="fontawesome" name="angle-right" />
|
||||
@ -168,10 +179,11 @@ class Search extends React.Component {
|
||||
}
|
||||
|
||||
renderPlaylists(playlists, spotify_search_enabled) {
|
||||
const encodedTerm = encodeURIComponent(this.state.term);
|
||||
return (
|
||||
<div>
|
||||
<h4>
|
||||
<URILink type="search" uri={`search:all:${this.state.term}`}>
|
||||
<URILink uri={`iris:search:all:${encodedTerm}`}>
|
||||
{`Search `}
|
||||
</URILink>
|
||||
<Icon type="fontawesome" name="angle-right" />
|
||||
@ -186,17 +198,18 @@ class Search extends React.Component {
|
||||
}
|
||||
|
||||
renderTracks(tracks, spotify_search_enabled) {
|
||||
const encodedTerm = encodeURIComponent(this.state.term);
|
||||
return (
|
||||
<div>
|
||||
<h4>
|
||||
<URILink type="search" uri={`search:all:${this.state.term}`}>
|
||||
<URILink uri={`iris:search:all:${encodedTerm}`}>
|
||||
{`Search `}
|
||||
</URILink>
|
||||
<Icon type="fontawesome" name="angle-right" />
|
||||
{` Tracks`}
|
||||
</h4>
|
||||
<section className="list-wrapper">
|
||||
<TrackList tracks={tracks} uri={`iris:search:${this.state.type}:${this.state.term}`} show_source_icon />
|
||||
<TrackList tracks={tracks} uri={`iris:search:${this.state.type}:${encodedTerm}`} show_source_icon />
|
||||
<LazyLoadListener enabled={this.props.tracks_more && spotify_search_enabled} loadMore={() => this.loadMore('tracks')} />
|
||||
</section>
|
||||
</div>
|
||||
@ -204,16 +217,17 @@ class Search extends React.Component {
|
||||
}
|
||||
|
||||
renderAll(artists, albums, playlists, tracks, spotify_search_enabled) {
|
||||
const encodedTerm = encodeURIComponent(this.state.term);
|
||||
if (artists.length > 0) {
|
||||
var artists_section = (
|
||||
<section>
|
||||
<div className="inner">
|
||||
<URILink type="search" uri={`search:artist:${this.state.term}`}>
|
||||
<URILink uri={`iris:search:artist:${encodedTerm}`}>
|
||||
<h4>Artists</h4>
|
||||
</URILink>
|
||||
<ArtistGrid mini show_source_icon artists={artists.slice(0, 6)} />
|
||||
{artists.length >= 6 && (
|
||||
<URILink type="search" uri={`search:artist:${this.state.term}`} className="button button--default">
|
||||
<URILink uri={`iris:search:artist:${encodedTerm}`} className="button button--default">
|
||||
{`All artists (${artists.length})`}
|
||||
</URILink>
|
||||
)}
|
||||
@ -228,12 +242,12 @@ class Search extends React.Component {
|
||||
var albums_section = (
|
||||
<section>
|
||||
<div className="inner">
|
||||
<URILink type="search" uri={`search:album:${this.state.term}`}>
|
||||
<URILink uri={`iris:search:album:${encodedTerm}`}>
|
||||
<h4>Albums</h4>
|
||||
</URILink>
|
||||
<AlbumGrid mini show_source_icon albums={albums.slice(0, 6)} />
|
||||
{albums.length >= 6 && (
|
||||
<URILink type="search" uri={`search:album:${this.state.term}`} className="button button--default">
|
||||
<URILink uri={`iris:search:album:${encodedTerm}`} className="button button--default">
|
||||
{`All albums (${albums.length})`}
|
||||
</URILink>
|
||||
)}
|
||||
@ -248,12 +262,12 @@ class Search extends React.Component {
|
||||
var playlists_section = (
|
||||
<section>
|
||||
<div className="inner">
|
||||
<URILink type="search" uri={`search:playlist:${this.state.term}`}>
|
||||
<URILink uri={`iris:search:playlist:${encodedTerm}`}>
|
||||
<h4>Playlists</h4>
|
||||
</URILink>
|
||||
<PlaylistGrid mini show_source_icon playlists={playlists.slice(0, 6)} />
|
||||
{playlists.length >= 6 && (
|
||||
<URILink type="search" uri={`search:playlist:${this.state.term}`} className="button button--default">
|
||||
<URILink uri={`iris:search:playlist:${encodedTerm}`} className="button button--default">
|
||||
{`All playlists (${playlists.length})`}
|
||||
</URILink>
|
||||
)}
|
||||
@ -267,7 +281,7 @@ class Search extends React.Component {
|
||||
if (tracks.length > 0) {
|
||||
var tracks_section = (
|
||||
<section className="list-wrapper">
|
||||
<TrackList tracks={tracks} uri={`iris:search:${this.state.type}:${this.state.term}`} show_source_icon />
|
||||
<TrackList tracks={tracks} uri={`iris:search:${this.state.type}:${encodedTerm}`} show_source_icon />
|
||||
<LazyLoadListener loading={this.props.tracks_more && spotify_search_enabled} loadMore={() => this.loadMore('tracks')} />
|
||||
</section>
|
||||
);
|
||||
|
||||
@ -15,7 +15,6 @@
|
||||
|
||||
a {
|
||||
border: 0 !important;
|
||||
display: block;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
@ -73,9 +72,24 @@
|
||||
}
|
||||
|
||||
@include responsive($bp_medium) {
|
||||
padding: 40px 0 20px;
|
||||
|
||||
&__artwork {
|
||||
width: 28%;
|
||||
|
||||
.thumbnail {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
&__added-from {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
@include responsive($bp_small) {
|
||||
display: block;
|
||||
text-align: center;
|
||||
padding: 40px 0 20px;
|
||||
|
||||
&__artwork {
|
||||
width: auto;
|
||||
@ -92,10 +106,6 @@
|
||||
width: auto;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
&__added-from {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,12 +5,12 @@ const blacklist = [
|
||||
'followers/contains',
|
||||
'me/tracks',
|
||||
'me/albums',
|
||||
'me/following',
|
||||
'refresh_spotify_token'
|
||||
];
|
||||
function inBlacklist(url) {
|
||||
for (let item of blacklist) {
|
||||
if (url.indexOf(item) >= 0){
|
||||
console.info(`Ignoring cache for ${url}`);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -37,7 +37,7 @@ self.addEventListener('fetch', event => {
|
||||
const { request } = event;
|
||||
|
||||
event.respondWith(
|
||||
|
||||
|
||||
// Opens Cache objects that start with 'font'.
|
||||
caches.open('iris').then(cache => {
|
||||
return cache.match(request)
|
||||
@ -50,13 +50,17 @@ self.addEventListener('fetch', event => {
|
||||
return fetch(request)
|
||||
.then(liveResponse => {
|
||||
|
||||
const isBlacklisted = inBlacklist(request.url);
|
||||
|
||||
// Only cache successful GET requests
|
||||
if (!inBlacklist(request.url) &&
|
||||
if (!isBlacklisted &&
|
||||
request.method === 'GET' &&
|
||||
liveResponse.status >= 200 &&
|
||||
liveResponse.status < 400
|
||||
) {
|
||||
cache.put(request, liveResponse.clone());
|
||||
} else {
|
||||
console.info(`Not caching ${isBlacklisted ? '(blacklisted) ' : ''}${request.method} ${request.url}`);
|
||||
}
|
||||
|
||||
return liveResponse;
|
||||
|
||||
Reference in New Issue
Block a user