From 60df3d78b49fc909162bc50b93ac707ff1251c8f Mon Sep 17 00:00:00 2001 From: Qstick Date: Sun, 25 Aug 2019 01:09:57 -0400 Subject: [PATCH] Fixed: Track Progress custom filtering on artist index page --- .../src/Store/Actions/artistIndexActions.js | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/frontend/src/Store/Actions/artistIndexActions.js b/frontend/src/Store/Actions/artistIndexActions.js index 597844df6..427806b2b 100644 --- a/frontend/src/Store/Actions/artistIndexActions.js +++ b/frontend/src/Store/Actions/artistIndexActions.js @@ -1,6 +1,6 @@ import { createAction } from 'redux-actions'; import sortByName from 'Utilities/Array/sortByName'; -import { filterBuilderTypes, filterBuilderValueTypes, sortDirections } from 'Helpers/Props'; +import { filterBuilderTypes, filterBuilderValueTypes, filterTypePredicates, sortDirections } from 'Helpers/Props'; import createSetTableOptionReducer from './Creators/Reducers/createSetTableOptionReducer'; import createSetClientSideCollectionSortReducer from './Creators/Reducers/createSetClientSideCollectionSortReducer'; import createSetClientSideCollectionFilterReducer from './Creators/Reducers/createSetClientSideCollectionFilterReducer'; @@ -223,7 +223,27 @@ export const defaultState = { selectedFilterKey: 'all', filters, - filterPredicates, + + filterPredicates: { + ...filterPredicates, + + trackProgress: function(item, filterValue, type) { + const { statistics = {} } = item; + + const { + trackCount = 0, + trackFileCount + } = statistics; + + const progress = trackCount ? + trackFileCount / trackCount * 100 : + 100; + + const predicate = filterTypePredicates[type]; + + return predicate(progress, filterValue); + } + }, filterBuilderProps: [ {