Skip to content

Commit

Permalink
Mild refractor.
Browse files Browse the repository at this point in the history
  • Loading branch information
soup-bowl committed Nov 28, 2024
1 parent 21e176d commit 524c40e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
24 changes: 11 additions & 13 deletions src/modals/IPAddress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import { BootstrapDialog, BootstrapDialogTitle } from "./_shared"

export const MyIpAddressModal = () => {
const { connectionState } = useContext(ConnectionContext)
const [ips, setIPs] = useState<IPAddresses>({ ipv4: "N/A", ipv6: "N/A" })
const [addresses, setAddresses] = useState<IPAddresses>({ ipv4: "N/A", ipv6: "N/A" })
const [open, setOpen] = useState(false)
const handleOpen = () => setOpen(true)
const handleClose = () => setOpen(false)

useEffect(() => {
const fetchIPs = async () => {
try {
setIPs(await getBothIPAddresses())
setAddresses(await getBothIPAddresses())
} catch (error) {
console.error("Error fetching IP data:", error)
}
Expand Down Expand Up @@ -44,17 +44,17 @@ export const MyIpAddressModal = () => {
</Grid>
<Grid item xs={12} sm={10}>
<Stack direction="row" alignItems="center">
<Typography>{ips.ipv4}</Typography>
<IPAddressGeo ip={ips.ipv4} />
<Typography>{addresses.ipv4}</Typography>
<IPAddressGeo ip={addresses.ipv4} />
</Stack>
</Grid>
<Grid item xs={12} sm={2}>
<Typography fontWeight={700}>IP v6</Typography>
</Grid>
<Grid item xs={12} sm={10}>
<Stack direction="row" alignItems="center">
<Typography>{ips.ipv6}</Typography>
<IPAddressGeo ip={ips.ipv6} />
<Typography>{addresses.ipv6}</Typography>
<IPAddressGeo ip={addresses.ipv6} />
</Stack>
</Grid>
</Grid>
Expand Down Expand Up @@ -134,13 +134,11 @@ export const IPAddressGeo = ({ ip }: GeoProps) => {
</Grid>
</Grid>
) : (
<>
<Typography id="geo-modal-modal-description" my={2}>
Some browsers and Adblocking mechanisms block <Link href="https://ipinfo.io/">ipinfo.io</Link>, the API
we use to detect IP geolocation. There's nothing wrong with blocking this info, but as a result, we
can't show you the information.
</Typography>
</>
<Typography id="geo-modal-modal-description" my={2}>
Some browsers and Adblocking mechanisms block <Link href="https://ipinfo.io/">ipinfo.io</Link>, the API we
use to detect IP geolocation. There's nothing wrong with blocking this info, but as a result, we can't
show you the information.
</Typography>
)}
</DialogContent>
</BootstrapDialog>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/inspection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const InspectonResult = ({ url }: Props) => {
const navigate = useNavigate()
const [siteDetails, setSiteDetails] = useState<IInspectionDetails[]>([])
const [loading, setLoading] = useState<boolean>(true)
const [requestError, setRError] = useState<boolean>(false)
const [requestError, setRequestError] = useState<boolean>(false)

useEffect(() => {
const addSoftwareToList = (inspection: IInspectionDetails, type: string) => {
Expand All @@ -103,7 +103,7 @@ export const InspectonResult = ({ url }: Props) => {
response.technology.language.forEach((res) => addSoftwareToList(res, "Language"))
response.technology.server.forEach((res) => addSoftwareToList(res, "Server"))
})
.catch(() => setRError(true))
.catch(() => setRequestError(true))
.finally(() => setLoading(false))
}, [url, siteDetails, apiAgent])

Expand Down
3 changes: 1 addition & 2 deletions src/pages/scratchpad.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ const ScratchpadPage = () => {
fileInput.addEventListener("change", (event) => {
const files = (event.target as HTMLInputElement).files
if (files && files.length > 0) {
for (let i = 0; i < files.length; ++i) {
const file = files[i]
for (let file of files) {
const reader = new FileReader()

reader.onload = (e) => {
Expand Down

0 comments on commit 524c40e

Please sign in to comment.