Moving selector outside of mapStateToProps (d'oh)
This commit is contained in:
@ -19,6 +19,7 @@ import Loader from '../../components/Loader';
|
||||
import {
|
||||
makeLibrarySelector,
|
||||
makeProcessProgressSelector,
|
||||
getLibrarySource,
|
||||
} from '../../util/selectors';
|
||||
|
||||
const processKeys = [
|
||||
@ -329,29 +330,19 @@ class LibraryAlbums extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
const source = state.ui.library_albums_source ? state.ui.library_albums_source : 'all';
|
||||
|
||||
const libraryUris = [];
|
||||
if (source === 'all' || source === 'local') libraryUris.push('mopidy:library:albums');
|
||||
if (source === 'all' || source === 'spotify') libraryUris.push('spotify:library:albums');
|
||||
if (source === 'all' || source === 'google') libraryUris.push('google:library:albums');
|
||||
const librarySelector = makeLibrarySelector(libraryUris);
|
||||
const processProgressSelector = makeProcessProgressSelector(processKeys);
|
||||
|
||||
return {
|
||||
loading_progress: processProgressSelector(state),
|
||||
mopidy_uri_schemes: state.mopidy.uri_schemes,
|
||||
albums: librarySelector(state),
|
||||
google_available: (state.mopidy.uri_schemes && state.mopidy.uri_schemes.includes('gmusic:')),
|
||||
spotify_available: state.spotify.access_token,
|
||||
view: state.ui.library_albums_view,
|
||||
source,
|
||||
sort: state.ui.library_albums_sort,
|
||||
sort_reverse: state.ui.library_albums_sort_reverse,
|
||||
};
|
||||
};
|
||||
|
||||
const librarySelector = makeLibrarySelector('albums');
|
||||
const processProgressSelector = makeProcessProgressSelector(processKeys);
|
||||
const mapStateToProps = (state) => ({
|
||||
loading_progress: processProgressSelector(state),
|
||||
mopidy_uri_schemes: state.mopidy.uri_schemes,
|
||||
albums: librarySelector(state, 'albums'),
|
||||
google_available: (state.mopidy.uri_schemes && state.mopidy.uri_schemes.includes('gmusic:')),
|
||||
spotify_available: state.spotify.access_token,
|
||||
view: state.ui.library_albums_view,
|
||||
source: getLibrarySource(state, 'albums'),
|
||||
sort: state.ui.library_albums_sort,
|
||||
sort_reverse: state.ui.library_albums_sort_reverse,
|
||||
});
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
coreActions: bindActionCreators(coreActions, dispatch),
|
||||
uiActions: bindActionCreators(uiActions, dispatch),
|
||||
|
||||
@ -16,6 +16,7 @@ import Loader from '../../components/Loader';
|
||||
import {
|
||||
makeLibrarySelector,
|
||||
makeProcessProgressSelector,
|
||||
getLibrarySource,
|
||||
} from '../../util/selectors';
|
||||
|
||||
const processKeys = [
|
||||
@ -298,28 +299,19 @@ class LibraryArtists extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
const source = state.ui.library_artists_source || 'all';
|
||||
|
||||
const libraryUris = [];
|
||||
if (source === 'all' || source === 'local') libraryUris.push('mopidy:library:artists');
|
||||
if (source === 'all' || source === 'spotify') libraryUris.push('spotify:library:artists');
|
||||
if (source === 'all' || source === 'google') libraryUris.push('google:library:artists');
|
||||
const librarySelector = makeLibrarySelector(libraryUris);
|
||||
const processProgressSelector = makeProcessProgressSelector(processKeys);
|
||||
|
||||
return {
|
||||
loading_progress: processProgressSelector(state),
|
||||
mopidy_uri_schemes: state.mopidy.uri_schemes,
|
||||
google_available: (state.mopidy.uri_schemes && state.mopidy.uri_schemes.includes('gmusic:')),
|
||||
spotify_available: (state.spotify.access_token),
|
||||
artists: librarySelector(state),
|
||||
source,
|
||||
sort: (state.ui.library_artists_sort ? state.ui.library_artists_sort : null),
|
||||
sort_reverse: (state.ui.library_artists_sort_reverse ? state.ui.library_artists_sort_reverse : false),
|
||||
view: state.ui.library_artists_view,
|
||||
};
|
||||
};
|
||||
const librarySelector = makeLibrarySelector('artists');
|
||||
const processProgressSelector = makeProcessProgressSelector(processKeys);
|
||||
const mapStateToProps = (state) => ({
|
||||
loading_progress: processProgressSelector(state),
|
||||
mopidy_uri_schemes: state.mopidy.uri_schemes,
|
||||
google_available: (state.mopidy.uri_schemes && state.mopidy.uri_schemes.includes('gmusic:')),
|
||||
spotify_available: (state.spotify.access_token),
|
||||
artists: librarySelector(state, 'artists'),
|
||||
source: getLibrarySource(state, 'artists'),
|
||||
sort: (state.ui.library_artists_sort ? state.ui.library_artists_sort : null),
|
||||
sort_reverse: (state.ui.library_artists_sort_reverse ? state.ui.library_artists_sort_reverse : false),
|
||||
view: state.ui.library_artists_view,
|
||||
});
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
uiActions: bindActionCreators(uiActions, dispatch),
|
||||
|
||||
@ -126,6 +126,7 @@ class LibraryBrowse extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
const loadingSelector = makeLoadingSelector(['(.*)mopidy_library.browse(.*)']);
|
||||
const mapStateToProps = (state) => {
|
||||
const {
|
||||
mopidy: {
|
||||
@ -136,7 +137,6 @@ const mapStateToProps = (state) => {
|
||||
},
|
||||
} = state;
|
||||
const directory = _directory && _directory.uri === null ? _directory : null;
|
||||
const loadingSelector = makeLoadingSelector(['(.*)mopidy_library.browse(.*)']);
|
||||
|
||||
return {
|
||||
loading: loadingSelector(state),
|
||||
|
||||
@ -280,6 +280,7 @@ class LibraryBrowseDirectory extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
const loadingSelector = makeLoadingSelector(['mopidy_library.(browse|lookup)']);
|
||||
const mapStateToProps = (state, ownProps) => {
|
||||
const {
|
||||
mopidy: {
|
||||
@ -294,7 +295,6 @@ const mapStateToProps = (state, ownProps) => {
|
||||
const directory = _directory && uriMatcher.includes(_directory.uri)
|
||||
? _directory
|
||||
: undefined;
|
||||
const loadingSelector = makeLoadingSelector(['mopidy_library.(browse|lookup)']);
|
||||
|
||||
return {
|
||||
uri,
|
||||
|
||||
@ -18,6 +18,7 @@ import Loader from '../../components/Loader';
|
||||
import {
|
||||
makeLibrarySelector,
|
||||
makeProcessProgressSelector,
|
||||
getLibrarySource,
|
||||
} from '../../util/selectors';
|
||||
|
||||
const processKeys = [
|
||||
@ -304,8 +305,9 @@ class LibraryPlaylists extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
const librarySelector = makeLibrarySelector('playlists');
|
||||
const processProgressSelector = makeProcessProgressSelector(processKeys);
|
||||
const mapStateToProps = (state) => {
|
||||
const source = state.ui.library_playlists_source || 'all';
|
||||
const {
|
||||
spotify: {
|
||||
me: {
|
||||
@ -314,20 +316,13 @@ const mapStateToProps = (state) => {
|
||||
},
|
||||
} = state;
|
||||
|
||||
const libraryUris = [];
|
||||
if (source === 'all' || source === 'local') libraryUris.push('mopidy:library:playlists');
|
||||
if (source === 'all' || source === 'spotify') libraryUris.push('spotify:library:playlists');
|
||||
if (source === 'all' || source === 'google') libraryUris.push('google:library:playlists');
|
||||
const librarySelector = makeLibrarySelector(libraryUris);
|
||||
const processProgressSelector = makeProcessProgressSelector(processKeys);
|
||||
|
||||
return {
|
||||
slim_mode: state.ui.slim_mode,
|
||||
mopidy_uri_schemes: state.mopidy.uri_schemes,
|
||||
spotify_available: state.spotify.access_token,
|
||||
playlists: librarySelector(state),
|
||||
playlists: librarySelector(state, 'playlists'),
|
||||
loading_progress: processProgressSelector(state),
|
||||
source,
|
||||
source: getLibrarySource(state, 'playlists'),
|
||||
me_id,
|
||||
view: state.ui.library_playlists_view,
|
||||
sort: (state.ui.library_playlists_sort ? state.ui.library_playlists_sort : null),
|
||||
|
||||
@ -18,6 +18,7 @@ import Loader from '../../components/Loader';
|
||||
import {
|
||||
makeLibrarySelector,
|
||||
makeProcessProgressSelector,
|
||||
getLibrarySource,
|
||||
} from '../../util/selectors';
|
||||
|
||||
const processKeys = [
|
||||
@ -312,26 +313,18 @@ class LibraryTracks extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
const source = state.ui.library_tracks_source ? state.ui.library_tracks_source : 'all';
|
||||
|
||||
const libraryUris = [];
|
||||
if (source === 'all' || source === 'local') libraryUris.push('mopidy:library:tracks');
|
||||
if (source === 'all' || source === 'spotify') libraryUris.push('spotify:library:tracks');
|
||||
const librarySelector = makeLibrarySelector(libraryUris);
|
||||
const processProgressSelector = makeProcessProgressSelector(processKeys);
|
||||
|
||||
return {
|
||||
loading_progress: processProgressSelector(state),
|
||||
mopidy_uri_schemes: state.mopidy.uri_schemes,
|
||||
tracks: librarySelector(state),
|
||||
spotify_available: state.spotify.access_token,
|
||||
view: state.ui.library_tracks_view,
|
||||
source,
|
||||
sort: state.ui.library_tracks_sort,
|
||||
sort_reverse: state.ui.library_tracks_sort_reverse,
|
||||
};
|
||||
};
|
||||
const librarySelector = makeLibrarySelector('tracks');
|
||||
const processProgressSelector = makeProcessProgressSelector(processKeys);
|
||||
const mapStateToProps = (state) => ({
|
||||
loading_progress: processProgressSelector(state),
|
||||
mopidy_uri_schemes: state.mopidy.uri_schemes,
|
||||
tracks: librarySelector(state),
|
||||
spotify_available: state.spotify.access_token,
|
||||
view: state.ui.library_tracks_view,
|
||||
source: getLibrarySource(state, 'tracks'),
|
||||
sort: state.ui.library_tracks_sort,
|
||||
sort_reverse: state.ui.library_tracks_sort_reverse,
|
||||
});
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
coreActions: bindActionCreators(coreActions, dispatch),
|
||||
|
||||
Reference in New Issue
Block a user