Skip to content

Commit

Permalink
Allow SharedToggleItem label to be undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
jagodarybacka committed Jun 19, 2023
1 parent 7886ead commit da343f7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
6 changes: 1 addition & 5 deletions background/lib/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,7 @@ export function getEthereumNetwork(): EVMNetwork {
}

export function isProbablyEVMAddress(str: string): boolean {
if (
typeof str === "string" &&
str.length === 42 &&
normalizeHexAddress(str).startsWith("0x")
) {
if (str.length === 42 && normalizeHexAddress(str).startsWith("0x")) {
return true
}
return false
Expand Down
6 changes: 4 additions & 2 deletions ui/components/Shared/SharedToggleItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import SharedToggleButton from "./SharedToggleButton"
export const STARS_GREY_URL = "./images/stars_grey.svg"

type SharedToggleItemProps = {
label: string
label?: string
thumbnailURL?: string
checked: boolean
onChange: (toggleValue: boolean) => void
Expand All @@ -25,7 +25,9 @@ export default function SharedToggleItem({
<div className="text_wrap">
<div className="thumbnail" role="img" />
<label className="label ellipsis">
{isProbablyEVMAddress(label) ? truncateAddress(label) : label ?? ""}
{typeof label === "string" && isProbablyEVMAddress(label)
? truncateAddress(label)
: label ?? ""}
</label>
</div>
<SharedToggleButton onChange={onChange} value={checked} />
Expand Down

0 comments on commit da343f7

Please sign in to comment.