From 4366530409fd7b8dc557d9f5134d923212a25289 Mon Sep 17 00:00:00 2001 From: DaftFuzz <35006874+DaftFuzz@users.noreply.github.com> Date: Mon, 16 Oct 2023 16:21:40 +0100 Subject: [PATCH] Fixed: Calculating value for peers filter (#1900) Co-authored-by: Bogdan --- frontend/src/Store/Actions/releaseActions.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/frontend/src/Store/Actions/releaseActions.js b/frontend/src/Store/Actions/releaseActions.js index 803cb1da1..7ade2652d 100644 --- a/frontend/src/Store/Actions/releaseActions.js +++ b/frontend/src/Store/Actions/releaseActions.js @@ -3,7 +3,7 @@ import React from 'react'; import { createAction } from 'redux-actions'; import { batchActions } from 'redux-batched-actions'; import Icon from 'Components/Icon'; -import { filterBuilderTypes, filterBuilderValueTypes, icons, sortDirections } from 'Helpers/Props'; +import { filterBuilderTypes, filterBuilderValueTypes, filterTypePredicates, icons, sortDirections } from 'Helpers/Props'; import { createThunk, handleThunks } from 'Store/thunks'; import createAjaxRequest from 'Utilities/createAjaxRequest'; import getSectionState from 'Utilities/State/getSectionState'; @@ -169,6 +169,18 @@ export const defaultState = { } ], + filterPredicates: { + peers: function(item, filterValue, type) { + const predicate = filterTypePredicates[type]; + + const seeders = item.seeders || 0; + const leechers = item.leechers || 0; + const peers = seeders + leechers; + + return predicate(peers, filterValue); + } + }, + filterBuilderProps: [ { name: 'title',