From d91ff158f6521273ac6b3f60074eb12c74bb2e5b Mon Sep 17 00:00:00 2001 From: isstuev Date: Wed, 11 Dec 2024 19:22:33 +0100 Subject: [PATCH] fixes 3 --- ui/advancedFilter/FilterByColumn.tsx | 2 +- ui/advancedFilter/ItemByColumn.tsx | 2 +- ui/advancedFilter/filters/AddressFilter.tsx | 13 +++++++++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ui/advancedFilter/FilterByColumn.tsx b/ui/advancedFilter/FilterByColumn.tsx index cf24bf2aa9..3c997c1c4a 100644 --- a/ui/advancedFilter/FilterByColumn.tsx +++ b/ui/advancedFilter/FilterByColumn.tsx @@ -130,7 +130,7 @@ const FilterByColumn = ({ column, filters, columnName, handleFilterChange, searc const value = tokens ? Object.entries(tokens).map(([ address, token ]) => { - const mode = filters.token_contract_address_hashes_to_include?.find(i => i.toLowerCase() === address) ? + const mode = filters.token_contract_address_hashes_to_include?.find(i => i.toLowerCase() === address.toLowerCase()) ? 'include' as AssetFilterMode : 'exclude' as AssetFilterMode; return ({ token, mode }); diff --git a/ui/advancedFilter/ItemByColumn.tsx b/ui/advancedFilter/ItemByColumn.tsx index 03d75996a1..c9906d158d 100644 --- a/ui/advancedFilter/ItemByColumn.tsx +++ b/ui/advancedFilter/ItemByColumn.tsx @@ -33,7 +33,7 @@ const ItemByColumn = ({ item, column, isLoading }: Props) => { return { type.name }; } case 'method': - return item.method ? { item.method } : null; + return item.method ? { item.method } : null; case 'age': return ; case 'from': diff --git a/ui/advancedFilter/filters/AddressFilter.tsx b/ui/advancedFilter/filters/AddressFilter.tsx index 69f1357a99..9bb197a099 100644 --- a/ui/advancedFilter/filters/AddressFilter.tsx +++ b/ui/advancedFilter/filters/AddressFilter.tsx @@ -37,6 +37,15 @@ type InputProps = { onAddFieldClick: () => void; }; +type AddressFilter = { + address: string; + mode: AddressFilterMode; +}; + +function addressFilterToKey(filter: AddressFilter) { + return `${ filter.address.toLowerCase() }-${ filter.mode }`; +} + const AddressFilterInput = ({ address, mode, onModeChange, onChange, onClear, isLast, onAddFieldClick }: InputProps) => { return ( @@ -78,7 +87,7 @@ const emptyItem = { address: '', mode: 'include' as AddressFilterMode }; const AddressFilter = ({ type, value = [], handleFilterChange, onClose }: Props) => { const [ currentValue, setCurrentValue ] = - React.useState>([ ...value, emptyItem ]); + React.useState>([ ...value, emptyItem ]); const handleModeSelectChange = React.useCallback((index: number) => (event: React.ChangeEvent) => { const value = event.target.value as AddressFilterMode; @@ -126,7 +135,7 @@ const AddressFilter = ({ type, value = [], handleFilterChange, onClose }: Props) i.address).map(i => JSON.stringify(i)).sort(), value.map(i => JSON.stringify(i)).sort()) } + isTouched={ !isEqual(currentValue.filter(i => i.address).map(addressFilterToKey).sort(), value.map(addressFilterToKey).sort()) } onFilter={ onFilter } onReset={ onReset } onClose={ onClose }