Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/934 validators filters #946

Merged
merged 7 commits into from
Sep 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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