Version 3.0.4; Filter on playlists

This commit is contained in:
James Barnsley
2017-07-06 08:11:15 +12:00
parent 77b143ea01
commit 7c05d7c9e4
4 changed files with 41 additions and 12 deletions

View File

@ -12,7 +12,7 @@ from handlers import WebsocketHandler, HttpHandler
from core import IrisCore
logger = logging.getLogger(__name__)
__version__ = '3.0.3'
__version__ = '3.0.4'
##
# Core extension class

View File

@ -47,16 +47,6 @@ class Settings extends React.Component{
changed = true
}
if (newProps.mopidy.host != this.state.mopidy_host && this.state.input_in_focus != 'mopidy_host'){
state.mopidy_host = newProps.mopidy.host
changed = true
}
if (newProps.mopidy.port != this.state.mopidy_port && this.state.input_in_focus != 'mopidy_port'){
state.mopidy_port = newProps.mopidy.port
changed = true
}
if (newProps.pusher.username != this.state.pusher_username && this.state.input_in_focus != 'pusher_username'){
state.pusher_username = newProps.pusher.username
changed = true

View File

@ -58,8 +58,28 @@ class LibraryPlaylists extends React.Component{
var playlists = []
for (var i = 0; i < this.props.library_playlists.length; i++){
var uri = this.props.library_playlists[i]
var owner_id = helpers.getFromUri('playlistowner',uri)
if (this.props.playlists.hasOwnProperty(uri)){
playlists.push(this.props.playlists[uri])
switch (this.props.filter){
case 'only_mine':
if (this.props.me_id && owner_id == this.props.me_id){
playlists.push(this.props.playlists[uri])
}
break
case 'only_others':
if (!this.props.me_id || owner_id != this.props.me_id){
playlists.push(this.props.playlists[uri])
}
break
default:
playlists.push(this.props.playlists[uri])
break
}
}
}
@ -113,6 +133,21 @@ class LibraryPlaylists extends React.Component{
render(){
var filter_options = [
{
value: 'all',
label: 'All'
},
{
value: 'only_mine',
label: 'Owned by me'
},
{
value: 'only_others',
label: 'I\'m following'
}
]
var view_options = [
{
value: 'thumbnails',
@ -149,6 +184,7 @@ class LibraryPlaylists extends React.Component{
var options = (
<span>
<DropdownField icon="filter" name="Filter" value={this.props.filter} options={filter_options} handleChange={val => {this.props.uiActions.set({ library_playlists_filter: val}); this.props.uiActions.hideContextMenu() }} />
<DropdownField icon="sort" name="Sort" value={this.props.sort} options={sort_options} reverse={this.props.sort_reverse} handleChange={val => {this.setSort(val); this.props.uiActions.hideContextMenu() }} />
<DropdownField icon="eye" name="View" value={this.props.view} options={view_options} handleChange={val => {this.props.uiActions.set({ library_playlists_view: val}); this.props.uiActions.hideContextMenu() }} />
<button onClick={ () => this.props.uiActions.openModal('create_playlist', {} ) }>
@ -177,7 +213,9 @@ class LibraryPlaylists extends React.Component{
const mapStateToProps = (state, ownProps) => {
return {
load_queue: state.ui.load_queue,
me_id: (state.spotify.me ? state.spotify.me.id : (state.ui.config && state.ui.config.spotify_username ? state.ui.config.spotify_username : false)),
view: state.ui.library_playlists_view,
filter: (state.ui.library_playlists_filter ? state.ui.library_playlists_filter : 'all'),
sort: (state.ui.library_playlists_sort ? state.ui.library_playlists_sort : 'name'),
sort_reverse: (state.ui.library_playlists_sort_reverse ? true : false),
library_playlists: state.ui.library_playlists,

View File

@ -34,6 +34,7 @@
display: none;
box-shadow: 2px 3px 6px rgba(0,0,0,0.2);
border-radius: 3px;
min-width: 120px;
&:before {
content: '';