2016-10-20 21:38:01 +13:00
|
|
|
|
2019-02-10 19:51:33 +13:00
|
|
|
import React from 'react';
|
2019-01-14 16:50:21 +13:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
import { bindActionCreators } from 'redux';
|
2019-01-22 21:46:56 +13:00
|
|
|
import ErrorMessage from '../components/ErrorMessage';
|
2020-08-15 21:05:00 +12:00
|
|
|
import Button from '../components/Button';
|
2019-09-05 15:36:11 +12:00
|
|
|
import TrackList from '../components/TrackList';
|
|
|
|
|
import Thumbnail from '../components/Thumbnail';
|
2020-08-08 22:17:31 +12:00
|
|
|
import PinButton from '../components/Fields/PinButton';
|
|
|
|
|
import { nice_number } from '../components/NiceNumber';
|
2020-07-08 20:15:14 +12:00
|
|
|
import { Dater, dater } from '../components/Dater';
|
2019-09-05 15:36:11 +12:00
|
|
|
import FollowButton from '../components/Fields/FollowButton';
|
2019-09-10 06:59:44 +12:00
|
|
|
import Loader from '../components/Loader';
|
2019-09-05 15:36:11 +12:00
|
|
|
import ContextMenuTrigger from '../components/ContextMenuTrigger';
|
|
|
|
|
import URILink from '../components/URILink';
|
|
|
|
|
import Icon from '../components/Icon';
|
2020-11-07 16:46:09 +13:00
|
|
|
import DropdownField from '../components/Fields/DropdownField';
|
2019-09-05 15:36:11 +12:00
|
|
|
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';
|
2020-03-03 16:39:37 +13:00
|
|
|
import {
|
|
|
|
|
uriSource,
|
|
|
|
|
getFromUri,
|
|
|
|
|
sourceIcon,
|
2020-05-12 20:32:48 +12:00
|
|
|
decodeMopidyUri,
|
2020-03-03 16:39:37 +13:00
|
|
|
} from '../util/helpers';
|
2020-11-07 16:46:09 +13:00
|
|
|
import { trackEvent } from '../components/Trackable';
|
2020-07-08 20:15:14 +12:00
|
|
|
import { i18n, I18n } from '../locale';
|
2020-09-23 20:59:06 +12:00
|
|
|
import { makeItemSelector, makeLoadingSelector } from '../util/selectors';
|
2020-11-01 23:09:06 +13:00
|
|
|
import { sortItems } from '../util/arrays';
|
2019-09-05 15:36:11 +12:00
|
|
|
|
2019-09-10 06:59:44 +12:00
|
|
|
class Playlist extends React.Component {
|
2019-09-05 15:36:11 +12:00
|
|
|
constructor(props) {
|
|
|
|
|
super(props);
|
|
|
|
|
|
2019-11-15 13:50:39 +13:00
|
|
|
let { uri } = props;
|
2019-09-05 15:36:11 +12:00
|
|
|
|
|
|
|
|
// Spotify upgraded their playlists URI to remove user component (Sept 2018)
|
|
|
|
|
// We accept the old format, and redirect to the new one
|
|
|
|
|
if (uri.includes('spotify:user:')) {
|
|
|
|
|
uri = uri.replace(/spotify:user:([^:]*?):/i, 'spotify:');
|
2019-11-15 13:50:39 +13:00
|
|
|
props.history.push(`/playlist/${encodeURIComponent(uri)}`);
|
2019-09-05 15:36:11 +12:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
componentDidMount() {
|
2020-09-09 07:54:19 +12:00
|
|
|
const { coreActions: { loadItem }, uri } = this.props;
|
2019-09-05 15:36:11 +12:00
|
|
|
this.setWindowTitle();
|
2020-09-09 21:30:47 +12:00
|
|
|
loadItem(uri, { full: true });
|
2019-09-05 15:36:11 +12:00
|
|
|
}
|
|
|
|
|
|
2020-03-11 20:40:20 +13:00
|
|
|
componentDidUpdate = ({
|
|
|
|
|
uri: prevUri,
|
|
|
|
|
playlist: prevPlaylist,
|
|
|
|
|
}) => {
|
|
|
|
|
const {
|
|
|
|
|
uri,
|
|
|
|
|
playlist,
|
|
|
|
|
coreActions: {
|
2020-09-09 07:54:19 +12:00
|
|
|
loadItem,
|
2020-03-11 20:40:20 +13:00
|
|
|
},
|
|
|
|
|
history: {
|
|
|
|
|
push,
|
|
|
|
|
},
|
|
|
|
|
} = this.props;
|
2020-04-16 16:24:47 +12:00
|
|
|
|
2020-03-11 20:40:20 +13:00
|
|
|
if (prevPlaylist && playlist && prevPlaylist.moved_to !== playlist.moved_to) {
|
|
|
|
|
push(`/playlist/${encodeURIComponent(playlist.moved_to)}`);
|
2019-09-05 15:36:11 +12:00
|
|
|
}
|
|
|
|
|
|
2020-03-11 20:40:20 +13:00
|
|
|
if (uri !== prevUri) {
|
2020-09-09 21:30:47 +12:00
|
|
|
loadItem(uri, { full: true });
|
2019-09-05 15:36:11 +12:00
|
|
|
}
|
|
|
|
|
|
2020-03-11 20:40:20 +13:00
|
|
|
if (!prevPlaylist && playlist) this.setWindowTitle(playlist);
|
|
|
|
|
if (prevUri !== uri && playlist) this.setWindowTitle(playlist);
|
2019-09-05 15:36:11 +12:00
|
|
|
}
|
|
|
|
|
|
2020-07-08 20:15:14 +12:00
|
|
|
setWindowTitle = (playlist = this.props.playlist) => {
|
|
|
|
|
const { uiActions: { setWindowTitle } } = this.props;
|
|
|
|
|
setWindowTitle(
|
|
|
|
|
playlist ? i18n('playlist.title_window', { name: playlist.name }) : i18n('playlist.title')
|
|
|
|
|
);
|
2019-09-05 15:36:11 +12:00
|
|
|
}
|
|
|
|
|
|
2020-07-08 20:15:14 +12:00
|
|
|
handleContextMenu = (e) => {
|
|
|
|
|
const {
|
|
|
|
|
uiActions: {
|
|
|
|
|
showContextMenu,
|
|
|
|
|
},
|
|
|
|
|
playlist,
|
|
|
|
|
uri,
|
|
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
|
|
showContextMenu({
|
2019-09-05 15:36:11 +12:00
|
|
|
e,
|
|
|
|
|
context: 'playlist',
|
2020-07-08 20:15:14 +12:00
|
|
|
items: [playlist],
|
|
|
|
|
uris: [uri],
|
|
|
|
|
});
|
2019-09-05 15:36:11 +12:00
|
|
|
}
|
|
|
|
|
|
2020-07-08 20:15:14 +12:00
|
|
|
play = () => {
|
|
|
|
|
const {
|
|
|
|
|
mopidyActions: {
|
|
|
|
|
playPlaylist,
|
|
|
|
|
},
|
|
|
|
|
playlist: {
|
|
|
|
|
uri,
|
|
|
|
|
},
|
|
|
|
|
} = this.props;
|
2016-11-11 09:33:35 +13:00
|
|
|
|
2020-07-08 20:15:14 +12:00
|
|
|
playPlaylist(uri);
|
2019-09-05 15:36:11 +12:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO: Once deletion occurs, remove playlist from global playlists list
|
2020-07-08 20:15:14 +12:00
|
|
|
delete = () => {
|
|
|
|
|
const {
|
|
|
|
|
mopidyActions: {
|
|
|
|
|
deletePlaylist,
|
|
|
|
|
},
|
|
|
|
|
playlist: {
|
|
|
|
|
uri,
|
|
|
|
|
},
|
|
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
|
|
deletePlaylist(uri);
|
2019-09-05 15:36:11 +12:00
|
|
|
}
|
|
|
|
|
|
2020-11-07 16:46:09 +13:00
|
|
|
onChangeSort = (value) => {
|
|
|
|
|
const {
|
|
|
|
|
sort,
|
|
|
|
|
sort_reverse,
|
|
|
|
|
uiActions: {
|
|
|
|
|
set,
|
|
|
|
|
hideContextMenu,
|
|
|
|
|
},
|
|
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
|
|
let reverse = false;
|
|
|
|
|
if (value !== null && sort === value) {
|
|
|
|
|
reverse = !sort_reverse;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set({
|
|
|
|
|
playlist_tracks_sort_reverse: reverse,
|
|
|
|
|
playlist_tracks_sort: value,
|
|
|
|
|
});
|
|
|
|
|
hideContextMenu();
|
|
|
|
|
trackEvent({ category: 'Playlist', action: 'SortTracks', label: `${value} ${reverse ? 'DESC' : 'ASC'}` });
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-08 20:15:14 +12:00
|
|
|
reorderTracks = (indexes, index) => {
|
|
|
|
|
const {
|
|
|
|
|
coreActions: {
|
|
|
|
|
reorderPlaylistTracks,
|
|
|
|
|
},
|
2020-11-07 16:46:09 +13:00
|
|
|
uiActions: {
|
|
|
|
|
createNotification,
|
|
|
|
|
},
|
2020-07-08 20:15:14 +12:00
|
|
|
playlist: {
|
|
|
|
|
uri,
|
|
|
|
|
snapshot_id,
|
2020-11-07 16:46:09 +13:00
|
|
|
tracks,
|
2020-07-08 20:15:14 +12:00
|
|
|
},
|
2020-11-07 16:46:09 +13:00
|
|
|
sort,
|
|
|
|
|
sort_reverse,
|
2020-07-08 20:15:14 +12:00
|
|
|
} = this.props;
|
|
|
|
|
|
2020-11-07 16:46:09 +13:00
|
|
|
if (sort !== 'sort_id') {
|
|
|
|
|
createNotification({
|
|
|
|
|
content: i18n('errors.cannot_reorder.title'),
|
|
|
|
|
description: i18n('errors.cannot_reorder.description'),
|
|
|
|
|
level: 'error',
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (sort_reverse) {
|
|
|
|
|
const count = tracks.length - 1;
|
|
|
|
|
index = count - index + 1;
|
|
|
|
|
indexes = indexes.map((index) => count - index);
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-08 20:15:14 +12:00
|
|
|
reorderPlaylistTracks(uri, indexes, index, snapshot_id);
|
2019-09-05 15:36:11 +12:00
|
|
|
}
|
|
|
|
|
|
2020-07-08 20:15:14 +12:00
|
|
|
removeTracks = (tracks_indexes) => {
|
2020-09-04 09:21:42 +12:00
|
|
|
const {
|
|
|
|
|
coreActions: {
|
|
|
|
|
removeTracksFromPlaylist,
|
|
|
|
|
},
|
|
|
|
|
playlist: {
|
|
|
|
|
uri,
|
|
|
|
|
},
|
|
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
|
|
removeTracksFromPlaylist(uri, tracks_indexes);
|
2019-09-05 15:36:11 +12:00
|
|
|
}
|
|
|
|
|
|
2020-07-08 20:15:14 +12:00
|
|
|
inLibrary = () => {
|
|
|
|
|
const { uri } = this.props;
|
|
|
|
|
const libraryName = `${uriSource(uri)}_library_playlists`;
|
2020-07-23 21:07:08 +12:00
|
|
|
const { [libraryName]: library } = this.props;
|
|
|
|
|
|
|
|
|
|
if (!library) return false;
|
|
|
|
|
|
2020-07-08 20:15:14 +12:00
|
|
|
return library.indexOf(uri) > -1;
|
2019-09-05 15:36:11 +12:00
|
|
|
}
|
|
|
|
|
|
2020-08-08 22:17:31 +12:00
|
|
|
togglePinned = () => {
|
|
|
|
|
const {
|
|
|
|
|
uri,
|
|
|
|
|
coreActions: {
|
|
|
|
|
addPinned,
|
|
|
|
|
removePinned,
|
|
|
|
|
},
|
|
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
|
|
if (this.isPinned()) {
|
|
|
|
|
removePinned(uri);
|
|
|
|
|
} else {
|
|
|
|
|
addPinned(uri);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-08 20:15:14 +12:00
|
|
|
renderActions = () => {
|
|
|
|
|
const {
|
|
|
|
|
uri,
|
|
|
|
|
playlist: {
|
|
|
|
|
can_edit,
|
2020-08-15 21:05:00 +12:00
|
|
|
name,
|
2020-09-07 21:04:28 +12:00
|
|
|
in_library,
|
2020-07-08 20:15:14 +12:00
|
|
|
},
|
|
|
|
|
} = this.props;
|
|
|
|
|
|
2020-08-15 21:05:00 +12:00
|
|
|
switch (uriSource(uri)) {
|
2019-09-05 15:36:11 +12:00
|
|
|
case 'm3u':
|
|
|
|
|
return (
|
|
|
|
|
<div className="actions">
|
2020-08-16 20:00:10 +12:00
|
|
|
<Button
|
|
|
|
|
type="primary"
|
|
|
|
|
onClick={this.play}
|
|
|
|
|
tracking={{ category: 'Playlist', action: 'Play' }}
|
|
|
|
|
>
|
2020-07-08 20:15:14 +12:00
|
|
|
<I18n path="actions.play" />
|
2020-08-15 21:05:00 +12:00
|
|
|
</Button>
|
2020-08-16 20:00:10 +12:00
|
|
|
<Button
|
|
|
|
|
to={`/playlist/${encodeURIComponent(uri)}/edit`}
|
|
|
|
|
tracking={{ category: 'Playlist', action: 'Edit' }}
|
|
|
|
|
>
|
2020-07-08 20:15:14 +12:00
|
|
|
<I18n path="actions.edit" />
|
2020-08-15 21:05:00 +12:00
|
|
|
</Button>
|
|
|
|
|
<PinButton item={{ uri, name }} />
|
2020-07-08 20:15:14 +12:00
|
|
|
<ContextMenuTrigger onTrigger={this.handleContextMenu} />
|
2019-09-05 15:36:11 +12:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
case 'spotify':
|
2020-07-08 20:15:14 +12:00
|
|
|
if (can_edit) {
|
2019-09-05 15:36:11 +12:00
|
|
|
return (
|
|
|
|
|
<div className="actions">
|
2020-08-16 20:00:10 +12:00
|
|
|
<Button
|
|
|
|
|
type="primary"
|
|
|
|
|
onClick={this.play}
|
|
|
|
|
tracking={{ category: 'Playlist', action: 'Play' }}
|
|
|
|
|
>
|
2020-07-08 20:15:14 +12:00
|
|
|
<I18n path="actions.play" />
|
2020-08-15 21:05:00 +12:00
|
|
|
</Button>
|
2020-08-16 20:00:10 +12:00
|
|
|
<Button
|
|
|
|
|
to={`/playlist/${encodeURIComponent(uri)}/edit`}
|
|
|
|
|
tracking={{ category: 'Playlist', action: 'Edit' }}
|
|
|
|
|
>
|
2020-07-08 20:15:14 +12:00
|
|
|
<I18n path="actions.edit" />
|
2020-08-15 21:05:00 +12:00
|
|
|
</Button>
|
|
|
|
|
<PinButton item={{ uri, name }} />
|
2020-07-08 20:15:14 +12:00
|
|
|
<ContextMenuTrigger onTrigger={this.handleContextMenu} />
|
2019-09-05 15:36:11 +12:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
return (
|
|
|
|
|
<div className="actions">
|
2020-08-16 20:00:10 +12:00
|
|
|
<Button
|
|
|
|
|
type="primary"
|
|
|
|
|
onClick={this.play}
|
|
|
|
|
tracking={{ category: 'Playlist', action: 'Play' }}
|
|
|
|
|
>
|
2020-07-08 20:15:14 +12:00
|
|
|
<I18n path="actions.play" />
|
2020-08-15 21:05:00 +12:00
|
|
|
</Button>
|
2020-07-08 20:15:14 +12:00
|
|
|
<FollowButton
|
|
|
|
|
uri={uri}
|
2020-09-07 21:04:28 +12:00
|
|
|
is_following={in_library}
|
2020-07-08 20:15:14 +12:00
|
|
|
/>
|
2020-08-15 21:05:00 +12:00
|
|
|
<PinButton item={{ uri, name }} />
|
2020-07-08 20:15:14 +12:00
|
|
|
<ContextMenuTrigger onTrigger={this.handleContextMenu} />
|
2019-09-05 15:36:11 +12:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return (
|
|
|
|
|
<div className="actions">
|
2020-08-16 20:00:10 +12:00
|
|
|
<Button
|
|
|
|
|
type="primary"
|
|
|
|
|
onClick={this.play}
|
|
|
|
|
tracking={{ category: 'Playlist', action: 'Play' }}
|
|
|
|
|
>
|
2020-07-08 20:15:14 +12:00
|
|
|
<I18n path="actions.play" />
|
2020-08-15 21:05:00 +12:00
|
|
|
</Button>
|
|
|
|
|
<PinButton item={{ uri, name }} />
|
2020-07-08 20:15:14 +12:00
|
|
|
<ContextMenuTrigger onTrigger={this.handleContextMenu} />
|
2019-09-05 15:36:11 +12:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-08 20:15:14 +12:00
|
|
|
render = () => {
|
|
|
|
|
const {
|
|
|
|
|
uri,
|
2020-09-04 09:21:42 +12:00
|
|
|
playlist,
|
2020-09-23 20:59:06 +12:00
|
|
|
loading,
|
2020-07-08 20:15:14 +12:00
|
|
|
slim_mode,
|
2020-11-07 16:46:09 +13:00
|
|
|
sort,
|
|
|
|
|
sort_reverse,
|
2020-07-08 20:15:14 +12:00
|
|
|
} = this.props;
|
|
|
|
|
|
2020-09-04 09:21:42 +12:00
|
|
|
if (!playlist) {
|
2020-09-23 20:59:06 +12:00
|
|
|
if (loading) {
|
2020-09-17 20:58:30 +12:00
|
|
|
return <Loader body loading />;
|
2019-09-05 15:36:11 +12:00
|
|
|
}
|
|
|
|
|
return (
|
|
|
|
|
<ErrorMessage type="not-found" title="Not found">
|
2019-09-10 06:59:44 +12:00
|
|
|
<p>
|
2020-07-08 20:15:14 +12:00
|
|
|
<I18n path="errors.uri_not_found" uri={uri} />
|
2019-09-05 15:36:11 +12:00
|
|
|
</p>
|
|
|
|
|
</ErrorMessage>
|
2019-09-10 06:59:44 +12:00
|
|
|
);
|
2019-09-05 15:36:11 +12:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let context = 'playlist';
|
|
|
|
|
if (playlist.can_edit) {
|
|
|
|
|
context = 'editable-playlist';
|
|
|
|
|
}
|
2020-11-07 16:46:09 +13:00
|
|
|
let {
|
|
|
|
|
playlist: {
|
|
|
|
|
tracks,
|
|
|
|
|
},
|
|
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
|
|
if (sort && tracks) {
|
|
|
|
|
tracks = sortItems(tracks, sort, sort_reverse);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const sort_options = [
|
|
|
|
|
{
|
|
|
|
|
value: null,
|
|
|
|
|
label: i18n('playlist.tracks.sort.default'),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
value: 'sort_id',
|
|
|
|
|
label: i18n('playlist.tracks.sort.sort_id'),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
value: 'added_at',
|
|
|
|
|
label: i18n('playlist.tracks.sort.added_at'),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
value: 'name',
|
|
|
|
|
label: i18n('playlist.tracks.sort.name'),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
value: 'artists.first.name',
|
|
|
|
|
label: i18n('playlist.tracks.sort.artist'),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
value: 'album.name',
|
|
|
|
|
label: i18n('playlist.tracks.sort.album'),
|
|
|
|
|
},
|
|
|
|
|
];
|
2019-09-05 15:36:11 +12:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="view playlist-view content-wrapper preserve-3d">
|
|
|
|
|
|
|
|
|
|
<div className="thumbnail-wrapper">
|
2020-04-17 21:44:49 +12:00
|
|
|
<Thumbnail size="large" glow canZoom images={playlist.images} type="playlist" />
|
2019-09-05 15:36:11 +12:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="title">
|
|
|
|
|
<h1>{playlist.name}</h1>
|
2020-07-08 20:15:14 +12:00
|
|
|
{playlist.description && (
|
|
|
|
|
<h2
|
|
|
|
|
className="description"
|
|
|
|
|
dangerouslySetInnerHTML={{ __html: playlist.description }}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
2019-09-05 15:36:11 +12:00
|
|
|
|
|
|
|
|
<ul className="details">
|
2020-07-08 20:15:14 +12:00
|
|
|
{!slim_mode && (
|
|
|
|
|
<li className="source">
|
|
|
|
|
<Icon type="fontawesome" name={sourceIcon(playlist.uri)} />
|
|
|
|
|
</li>
|
|
|
|
|
)}
|
2020-09-06 13:53:22 +12:00
|
|
|
{playlist.user && (
|
2020-07-08 20:15:14 +12:00
|
|
|
<li>
|
|
|
|
|
<URILink
|
|
|
|
|
type="user"
|
2020-09-06 13:53:22 +12:00
|
|
|
uri={playlist.user.uri}
|
2020-07-08 20:15:14 +12:00
|
|
|
>
|
2020-09-06 13:53:22 +12:00
|
|
|
{playlist.user.name}
|
2020-07-08 20:15:14 +12:00
|
|
|
</URILink>
|
|
|
|
|
</li>
|
|
|
|
|
)}
|
2019-09-10 06:59:44 +12:00
|
|
|
<li>
|
2020-09-09 21:30:47 +12:00
|
|
|
<I18n path="specs.tracks" count={playlist.tracks ? playlist.tracks.length : 0} />
|
2019-09-05 15:36:11 +12:00
|
|
|
</li>
|
2020-07-08 20:15:14 +12:00
|
|
|
{!slim_mode && playlist.tracks && playlist.tracks_total > 0 && (
|
|
|
|
|
<li><Dater type="total-time" data={playlist.tracks} /></li>
|
|
|
|
|
)}
|
|
|
|
|
{!slim_mode && playlist.followers !== undefined && (
|
2019-09-10 06:59:44 +12:00
|
|
|
<li>
|
2020-07-08 20:15:14 +12:00
|
|
|
<I18n path="specs.followers" count={nice_number(playlist.followers)} />
|
2019-09-10 06:59:44 +12:00
|
|
|
</li>
|
2020-07-08 20:15:14 +12:00
|
|
|
)}
|
|
|
|
|
{!slim_mode && playlist.last_modified_date && (
|
2019-09-10 06:59:44 +12:00
|
|
|
<li>
|
2020-07-08 20:15:14 +12:00
|
|
|
<I18n path="specs.edited" date={dater('ago', playlist.last_modified_date)} />
|
2019-09-10 06:59:44 +12:00
|
|
|
</li>
|
2020-07-08 20:15:14 +12:00
|
|
|
)}
|
2019-09-05 15:36:11 +12:00
|
|
|
</ul>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{this.renderActions()}
|
|
|
|
|
|
2020-11-07 16:46:09 +13:00
|
|
|
<h4 className="no-bottom-margin">
|
|
|
|
|
<I18n path="playlist.tracks.title" />
|
|
|
|
|
<div className="actions-wrapper">
|
|
|
|
|
<DropdownField
|
|
|
|
|
icon="swap_vert"
|
|
|
|
|
name="Sort"
|
|
|
|
|
value={sort}
|
|
|
|
|
valueAsLabel
|
|
|
|
|
options={sort_options}
|
|
|
|
|
selected_icon={sort ? (sort_reverse ? 'keyboard_arrow_up' : 'keyboard_arrow_down') : null}
|
|
|
|
|
handleChange={this.onChangeSort}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</h4>
|
|
|
|
|
|
|
|
|
|
<section className="list-wrapper no-top-padding">
|
2020-09-20 21:04:40 +12:00
|
|
|
<TrackList
|
|
|
|
|
uri={playlist.uri}
|
|
|
|
|
className="playlist-track-list"
|
|
|
|
|
track_context={context}
|
2020-11-07 16:46:09 +13:00
|
|
|
tracks={tracks}
|
2020-09-20 21:04:40 +12:00
|
|
|
removeTracks={this.removeTracks}
|
|
|
|
|
reorderTracks={this.reorderTracks}
|
|
|
|
|
/>
|
|
|
|
|
</section>
|
2020-09-23 20:59:06 +12:00
|
|
|
|
|
|
|
|
{loading && <Loader body loading />}
|
2019-09-05 15:36:11 +12:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
2016-10-20 21:38:01 +13:00
|
|
|
}
|
|
|
|
|
|
2019-09-10 06:59:44 +12:00
|
|
|
const mapStateToProps = (state, ownProps) => {
|
2020-05-03 13:54:34 +12:00
|
|
|
const {
|
|
|
|
|
ui: {
|
|
|
|
|
allow_reporting,
|
|
|
|
|
slim_mode,
|
|
|
|
|
theme,
|
|
|
|
|
} = {},
|
|
|
|
|
spotify: {
|
|
|
|
|
library_playlists: spotify_library_playlists,
|
|
|
|
|
authorization: spotify_authorized,
|
2020-05-12 20:32:48 +12:00
|
|
|
me = {},
|
2020-05-03 13:54:34 +12:00
|
|
|
} = {},
|
|
|
|
|
mopidy: {
|
|
|
|
|
library_playlists: local_library_playlists,
|
|
|
|
|
} = {},
|
|
|
|
|
} = state;
|
|
|
|
|
|
2020-05-12 20:32:48 +12:00
|
|
|
const uri = decodeMopidyUri(ownProps.match.params.uri);
|
2020-09-23 20:59:06 +12:00
|
|
|
const playlistId = getFromUri('playlistid', uri);
|
|
|
|
|
const itemSelector = makeItemSelector(uri);
|
|
|
|
|
const loadingSelector = makeLoadingSelector([`(.*)${playlistId}(?!.*(following))(.*)`]);
|
2019-09-05 15:36:11 +12:00
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
uri,
|
2020-05-03 13:54:34 +12:00
|
|
|
allow_reporting,
|
|
|
|
|
slim_mode,
|
|
|
|
|
theme,
|
2020-09-23 20:59:06 +12:00
|
|
|
loading: loadingSelector(state),
|
|
|
|
|
playlist: itemSelector(state),
|
2020-05-03 13:54:34 +12:00
|
|
|
spotify_library_playlists,
|
|
|
|
|
local_library_playlists,
|
|
|
|
|
spotify_authorized,
|
2020-05-12 20:32:48 +12:00
|
|
|
spotify_userid: (me && me.id) || null,
|
2020-11-07 16:46:09 +13:00
|
|
|
sort: (state.ui.playlist_tracks_sort ? state.ui.playlist_tracks_sort : null),
|
|
|
|
|
sort_reverse: (!!state.ui.playlist_tracks_sort_reverse),
|
2019-09-05 15:36:11 +12:00
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const mapDispatchToProps = (dispatch) => ({
|
|
|
|
|
coreActions: bindActionCreators(coreActions, dispatch),
|
|
|
|
|
uiActions: bindActionCreators(uiActions, dispatch),
|
|
|
|
|
mopidyActions: bindActionCreators(mopidyActions, dispatch),
|
|
|
|
|
spotifyActions: bindActionCreators(spotifyActions, dispatch),
|
|
|
|
|
});
|
|
|
|
|
|
2019-09-10 06:59:44 +12:00
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(Playlist);
|