Popularity sorting (as default) for search

This commit is contained in:
James Barnsley
2018-06-11 21:12:11 +12:00
parent 558bad87e3
commit 7a94320d80
4 changed files with 46 additions and 21 deletions

View File

@ -67016,10 +67016,18 @@ var Search = function (_React$Component) {
var spotify_search_enabled = this.props.search_settings && this.props.search_settings.spotify;
if (this.props.sort == 'uri') {
var sort_map = this.props.uri_schemes_priority;
} else {
var sort_map = null;
var sort = this.props.sort;
var sort_reverse = this.props.sort_reverse;
var sort_map = null;
switch (this.props.sort) {
case 'uri':
sort_map = this.props.uri_schemes_priority;
break;
case 'followers.total':
sort_reverse = !sort_reverse;
break;
}
var artists = [];
@ -67029,7 +67037,7 @@ var Search = function (_React$Component) {
if (this.props.spotify_search_results.artists) {
artists = [].concat(_toConsumableArray(artists), _toConsumableArray(helpers.getIndexedRecords(this.props.artists, this.props.spotify_search_results.artists)));
}
artists = helpers.sortItems(artists, this.props.sort, this.props.sort_reverse, sort_map);
artists = helpers.sortItems(artists, sort, sort_reverse, sort_map);
var albums = [];
if (this.props.mopidy_search_results.albums) {
@ -67038,7 +67046,7 @@ var Search = function (_React$Component) {
if (this.props.spotify_search_results.albums) {
albums = [].concat(_toConsumableArray(albums), _toConsumableArray(helpers.getIndexedRecords(this.props.albums, this.props.spotify_search_results.albums)));
}
albums = helpers.sortItems(albums, this.props.sort, this.props.sort_reverse, sort_map);
albums = helpers.sortItems(albums, sort, sort_reverse, sort_map);
var playlists = [];
if (this.props.mopidy_search_results.playlists) {
@ -67047,7 +67055,7 @@ var Search = function (_React$Component) {
if (this.props.spotify_search_results.playlists) {
playlists = [].concat(_toConsumableArray(playlists), _toConsumableArray(helpers.getIndexedRecords(this.props.playlists, this.props.spotify_search_results.playlists)));
}
playlists = helpers.sortItems(playlists, this.props.sort, this.props.sort_reverse, sort_map);
playlists = helpers.sortItems(playlists, sort, sort_reverse, sort_map);
var tracks = [];
if (this.props.mopidy_search_results.tracks) {
@ -67056,7 +67064,8 @@ var Search = function (_React$Component) {
if (this.props.spotify_search_results.tracks) {
tracks = [].concat(_toConsumableArray(tracks), _toConsumableArray(this.props.spotify_search_results.tracks));
}
tracks = helpers.sortItems(tracks, this.props.sort, this.props.sort_reverse, sort_map);
tracks = helpers.sortItems(tracks, sort == 'followers.total' ? 'popularity' : sort, sort_reverse, sort_map);
switch (context) {
@ -67294,6 +67303,9 @@ var Search = function (_React$Component) {
var _this3 = this;
var sort_options = [{
value: 'followers.total',
label: 'Popularity'
}, {
value: 'name',
label: 'Name'
}, {
@ -67375,7 +67387,7 @@ var mapStateToProps = function mapStateToProps(state, ownProps) {
uri_schemes: state.mopidy.uri_schemes ? state.mopidy.uri_schemes : [],
mopidy_search_results: state.mopidy.search_results ? state.mopidy.search_results : {},
spotify_search_results: state.spotify.search_results ? state.spotify.search_results : {},
sort: state.ui.search_results_sort ? state.ui.search_results_sort : 'name',
sort: state.ui.search_results_sort ? state.ui.search_results_sort : 'followers.total',
sort_reverse: state.ui.search_results_sort_reverse ? true : false
};
};