From 8459205a5e7f1598cf98738e3a4e09b3658caa85 Mon Sep 17 00:00:00 2001 From: Qstick Date: Thu, 22 Apr 2021 22:45:11 -0400 Subject: [PATCH] Fixed: Sorts not working on Search page --- frontend/src/Search/SearchIndex.js | 1 + .../Search/Table/SearchIndexTableConnector.js | 6 ++---- frontend/src/Store/Actions/releaseActions.js | 21 +++++++++++++++---- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/frontend/src/Search/SearchIndex.js b/frontend/src/Search/SearchIndex.js index 166cfb2f9..0309c4666 100644 --- a/frontend/src/Search/SearchIndex.js +++ b/frontend/src/Search/SearchIndex.js @@ -261,6 +261,7 @@ class SearchIndex extends Component { filters={filters} sortKey={sortKey} sortDirection={sortDirection} + columns={columns} jumpToCharacter={jumpToCharacter} {...otherProps} /> diff --git a/frontend/src/Search/Table/SearchIndexTableConnector.js b/frontend/src/Search/Table/SearchIndexTableConnector.js index 5cc2aad5e..e73b9ab9a 100644 --- a/frontend/src/Search/Table/SearchIndexTableConnector.js +++ b/frontend/src/Search/Table/SearchIndexTableConnector.js @@ -7,14 +7,12 @@ import SearchIndexTable from './SearchIndexTable'; function createMapStateToProps() { return createSelector( (state) => state.app.dimensions, - (state) => state.releases, createUISettingsSelector(), - (dimensions, releases, uiSettings) => { + (dimensions, uiSettings) => { return { isSmallScreen: dimensions.isSmallScreen, longDateFormat: uiSettings.longDateFormat, - timeFormat: uiSettings.timeFormat, - ...releases + timeFormat: uiSettings.timeFormat }; } ); diff --git a/frontend/src/Store/Actions/releaseActions.js b/frontend/src/Store/Actions/releaseActions.js index 9b11515e6..d1dc5237d 100644 --- a/frontend/src/Store/Actions/releaseActions.js +++ b/frontend/src/Store/Actions/releaseActions.js @@ -28,6 +28,8 @@ export const defaultState = { items: [], sortKey: 'title', sortDirection: sortDirections.ASCENDING, + secondarySortKey: 'title', + secondarySortDirection: sortDirections.ASCENDING, defaults: { searchQuery: '', @@ -38,7 +40,7 @@ export const defaultState = { columns: [ { name: 'protocol', - label: translate('Source'), + label: translate('Protocol'), isSortable: true, isVisible: true }, @@ -105,17 +107,19 @@ export const defaultState = { ], sortPredicates: { - age: function(item, direction) { + age: function(item) { + console.log(item); return item.ageMinutes; }, - peers: function(item, direction) { + + peers: function(item) { const seeders = item.seeders || 0; const leechers = item.leechers || 0; return seeders * 1000000 + leechers; }, - indexerFlags: function(item, direction) { + indexerFlags: function(item) { const indexerFlags = item.indexerFlags; const releaseWeight = item.releaseWeight; @@ -124,6 +128,15 @@ export const defaultState = { } return releaseWeight; + }, + + category: function(item) { + if (item.categories.length > 0) { + const sortedCats = item.categories.filter((cat) => cat.name !== undefined).sort((c) => c.id); + const firstCat = sortedCats[0]; + + return firstCat.name; + } } },