diff --git a/src/pages/Popup/LocationInput.tsx b/src/pages/Popup/LocationInput.tsx index 7890c2a..e7a2d9a 100644 --- a/src/pages/Popup/LocationInput.tsx +++ b/src/pages/Popup/LocationInput.tsx @@ -39,8 +39,8 @@ const LocationInput = ({ chrome.storage.sync.set({ [type]: ipTypeValue }) } } else if (configuration === 'custom') { - chrome.storage.sync.get([type], (result) => { - result[type] && setValue(result[type]) + chrome.storage.sync.get([type], (storage) => { + storage[type] && setValue(storage[type]) }) } else if (configuration !== 'default') { setValue(configurations[configuration][type]) diff --git a/src/pages/Popup/LocationPage.tsx b/src/pages/Popup/LocationPage.tsx index 62a159e..c4b9353 100644 --- a/src/pages/Popup/LocationPage.tsx +++ b/src/pages/Popup/LocationPage.tsx @@ -14,10 +14,10 @@ const LocationPage = ({ tab }: LocationPageProps) => { const [configuration, setConfiguration] = useState('default') useEffect(() => { - chrome.storage.sync.get(['configuration', 'ipData'], (result) => { - result.configuration && setConfiguration(result.configuration) - if (result.ipData) { - setIP(result.ipData) + chrome.storage.sync.get(['configuration', 'ipData'], (storage) => { + storage.configuration && setConfiguration(storage.configuration) + if (storage.ipData) { + setIP(storage.ipData) } else { Promise.resolve(getIP()).then((ipData) => setIP(ipData)) } diff --git a/src/pages/Popup/SettingsCheckBox.tsx b/src/pages/Popup/SettingsCheckBox.tsx index 67efcbf..b7edba2 100644 --- a/src/pages/Popup/SettingsCheckBox.tsx +++ b/src/pages/Popup/SettingsCheckBox.tsx @@ -2,12 +2,14 @@ import { Label, Checkbox } from 'theme-ui' interface LocationPageProps { title: string + onChange?: () => void + checked?: boolean } -const SettingsCheckBox = ({ title }: LocationPageProps) => { +const SettingsCheckBox = ({ title, onChange, checked }: LocationPageProps) => { return ( ) diff --git a/src/pages/Popup/SettingsPage.tsx b/src/pages/Popup/SettingsPage.tsx index 86081d6..18f5c95 100644 --- a/src/pages/Popup/SettingsPage.tsx +++ b/src/pages/Popup/SettingsPage.tsx @@ -1,5 +1,6 @@ import { useState, useEffect } from 'react' -import { Box, Label, Checkbox, Select } from 'theme-ui' +import { Box, Label, Select } from 'theme-ui' +import setWebRtcPolicy from '../../utils/setWebRtcPolicy' import SettingsCheckBox from './SettingsCheckBox' interface LocationPageProps { @@ -7,9 +8,13 @@ interface LocationPageProps { } const SettingsPage = ({ tab }: LocationPageProps) => { - const [ip, setIP] = useState(null) + const [isWebRtcDisabled, setIsWebRtcDisabled] = useState(false) - useEffect(() => {}, []) + useEffect(() => { + chrome.storage.sync.get(['isWebRtcDisabled'], (storage) => { + storage.isWebRtcDisabled && setIsWebRtcDisabled(storage.isWebRtcDisabled) + }) + }, []) return ( { }} > Settings - + { + setWebRtcPolicy() + setIsWebRtcDisabled(!isWebRtcDisabled) + }} + checked={isWebRtcDisabled} + />