From 3a76962921ff6df462a38cb626e5e3e4f56588af Mon Sep 17 00:00:00 2001 From: z0ccc Date: Sat, 16 Apr 2022 13:10:53 -0400 Subject: [PATCH] Added locale settings for popup --- src/pages/Background/index.js | 3 +- src/pages/Popup/DebugSettings.js | 14 ++-- src/pages/Popup/LocaleSettings.js | 83 +++++++++++++++++++ src/pages/Popup/Popup.jsx | 10 ++- src/pages/Popup/index.css | 2 +- .../Background => utils}/countryLocales.js | 0 6 files changed, 97 insertions(+), 15 deletions(-) create mode 100644 src/pages/Popup/LocaleSettings.js rename src/{pages/Background => utils}/countryLocales.js (100%) diff --git a/src/pages/Background/index.js b/src/pages/Background/index.js index 28a17e5..8815deb 100644 --- a/src/pages/Background/index.js +++ b/src/pages/Background/index.js @@ -1,4 +1,5 @@ -import countryLocales from './countryLocales' +import countryLocales from '../../utils/countryLocales' + const attachTab = (tabId, ipData) => { chrome.storage.sync.get( diff --git a/src/pages/Popup/DebugSettings.js b/src/pages/Popup/DebugSettings.js index 13fdb04..b71a737 100644 --- a/src/pages/Popup/DebugSettings.js +++ b/src/pages/Popup/DebugSettings.js @@ -10,19 +10,13 @@ const detachDebugger = () => { }) } -const DebugSettings = ({ type, ip }) => { +const DebugSettings = ({ type, title, ip }) => { const [value, setValue] = useState('') const [matchIP, setMatchIP] = useState(false) const matchIPStorage = `${type}MatchIP` - // useEffect(() => { - // console.log(value, matchIP) - // }, [value, matchIP]) - useEffect(() => { chrome.storage.sync.get([type, matchIPStorage], (result) => { - console.log(1, result) - setMatchIP(result[matchIPStorage]) if (result[matchIPStorage]) { @@ -39,6 +33,8 @@ const DebugSettings = ({ type, ip }) => { // result[type] && setValue(ip[type]) // } + } else { + setValue(result[type]) } }) }, [ip, matchIPStorage, type]) @@ -63,7 +59,7 @@ const DebugSettings = ({ type, ip }) => { style={{ display: 'flex', justifyContent: 'space-between', - margin: '10px 0 0 0', + margin: '12px 0 0 0', }} >