Skip to content

Commit

Permalink
Feature/934 validators filters (#946)
Browse files Browse the repository at this point in the history
* Move hotspot picker logic from slice to component.

* Add validators and followed validators filter.

* Load validator rewards. Update validator border left color.

* Remove validator type checking in HotspotListItem.

* Fix hotspot lint error.

* Rename ElectedValidatorItem to ValidatorListItem.

* Convert validator list item hnt to currency.
  • Loading branch information
matthewcarlreetz authored Sep 20, 2021
1 parent fb3b13e commit 82c438c
Show file tree
Hide file tree
Showing 13 changed files with 391 additions and 255 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
"react-qr-code": "^1.0.3",
"react-redux": "^7.2.2",
"redux-thunk": "^2.3.0",
"tinycolor2": "^1.4.2",
"use-debounce": "^5.2.0",
"use-state-with-callback": "^2.0.3"
},
Expand All @@ -137,6 +138,7 @@
"@types/react-native": "^0.63.2",
"@types/react-redux": "^7.1.11",
"@types/react-test-renderer": "^16.9.2",
"@types/tinycolor2": "^1.4.3",
"@types/webpack-env": "^1.15.3",
"@typescript-eslint/eslint-plugin": "^4.1.0",
"@typescript-eslint/parser": "^4.1.0",
Expand Down
30 changes: 15 additions & 15 deletions src/components/HotspotListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import VisibilityOff from '../assets/images/visibility_off.svg'

type HotspotListItemProps = {
onPress?: (hotspot: Hotspot) => void
hotspot: Hotspot
gateway: Hotspot
totalReward?: Balance<NetworkTokens>
showCarot?: boolean
loading?: boolean
Expand All @@ -33,7 +33,7 @@ type HotspotListItemProps = {

const HotspotListItem = ({
onPress,
hotspot,
gateway,
totalReward,
loading = false,
showCarot = false,
Expand All @@ -48,7 +48,7 @@ const HotspotListItem = ({
const { t } = useTranslation()
const colors = useColors()
const { toggleConvertHntToCurrency, hntBalanceToDisplayVal } = useCurrency()
const handlePress = useCallback(() => onPress?.(hotspot), [hotspot, onPress])
const handlePress = useCallback(() => onPress?.(gateway), [gateway, onPress])
const [reward, setReward] = useState('')

const updateReward = useCallback(async () => {
Expand All @@ -63,21 +63,21 @@ const HotspotListItem = ({
}, [updateReward])

const locationText = useMemo(() => {
const { geocode: geo } = hotspot
const { geocode: geo } = gateway as Hotspot
if (!geo || (!geo.longStreet && !geo.longCity && !geo.shortCountry)) {
return t('hotspot_details.no_location_title')
}
return `${geo.longStreet}, ${geo.longCity}, ${geo.shortCountry}`
}, [hotspot, t])
}, [gateway, t])

const isRelayed = useMemo(() => isRelay(hotspot?.status?.listenAddrs), [
hotspot?.status,
const isRelayed = useMemo(() => isRelay(gateway?.status?.listenAddrs), [
gateway?.status,
])

const statusBackgroundColor = useMemo(() => {
if (hidden) return 'grayLightText'
return hotspot.status?.online === 'online' ? 'greenOnline' : 'yellow'
}, [hidden, hotspot.status?.online])
return gateway.status?.online === 'online' ? 'greenOnline' : 'yellow'
}, [hidden, gateway.status?.online])

return (
<Box marginBottom="xxs">
Expand Down Expand Up @@ -108,7 +108,7 @@ const HotspotListItem = ({
numberOfLines={2}
maxWidth={220}
>
{animalName(hotspot.address)}
{animalName(gateway.address)}
</Text>
{hidden && <VisibilityOff height={10} width={10} />}
</Box>
Expand Down Expand Up @@ -164,8 +164,8 @@ const HotspotListItem = ({
)}
{showRewardScale && (
<HexBadge
hotspotId={hotspot.address}
rewardScale={hotspot.rewardScale}
hotspotId={gateway.address}
rewardScale={(gateway as Hotspot).rewardScale}
pressable={false}
badge={false}
fontSize={12}
Expand All @@ -181,17 +181,17 @@ const HotspotListItem = ({
marginLeft="xs"
>
{t('generic.meters', {
distance: hotspot?.elevation || 0,
distance: (gateway as Hotspot)?.elevation || 0,
})}
</Text>
{hotspot?.gain !== undefined && (
{(gateway as Hotspot)?.gain !== undefined && (
<Text
color="grayText"
variant="regular"
fontSize={12}
marginLeft="xs"
>
{(hotspot.gain / 10).toFixed(1) +
{(((gateway as Hotspot).gain || 0) / 10).toFixed(1) +
t('antennas.onboarding.dbi')}
</Text>
)}
Expand Down
2 changes: 1 addition & 1 deletion src/features/hotspots/details/HotspotDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ const HotspotDetails = ({
pressable={false}
key={witness.address}
onPress={onSelectHotspot}
hotspot={witness as Hotspot}
gateway={witness as Hotspot}
showAddress={false}
distanceAway={getDistance(witness)}
showRewardScale
Expand Down
Loading

0 comments on commit 82c438c

Please sign in to comment.