diff --git a/src/index.tsx b/src/index.tsx index 68dac72..e2b5cab 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -3,20 +3,27 @@ import ReactDOM from 'react-dom/client' import './index.css' import App from './ui/App' -// import Debug from './ui/Debug' +import Debug from './ui/Debug' + +import { getConfigOption } from './utils/configuration' const root = ReactDOM.createRoot( document.getElementById('root') as HTMLElement ) +let isDebug = false; + +(async() => { + isDebug = await getConfigOption('debug_enabled') +}) + root.render( - + { + isDebug ? : + } ) -// If you want to start measuring performance in your app, pass a function -// to log results (for example: reportWebVitals(console.log)) -// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals import reportWebVitals from './utils/reportWebVitals' -reportWebVitals(console.log) \ No newline at end of file +isDebug && reportWebVitals(console.log) \ No newline at end of file diff --git a/src/utils/configuration.ts b/src/utils/configuration.ts index 3acdf37..5404718 100644 --- a/src/utils/configuration.ts +++ b/src/utils/configuration.ts @@ -20,6 +20,7 @@ let defaultConfig: Configuration cert_generated: false, theme: 'default', https_enabled: false, + debug_enabled: false } })() @@ -39,8 +40,9 @@ export interface Configuration { language: string customBackground: string cert_generated: boolean - theme: string; + theme: string https_enabled: boolean + debug_enabled: boolean } export async function setConfigOption(key: string, value: any): Promise { @@ -52,8 +54,9 @@ export async function setConfigOption(key: string, value: any): Promise { export async function getConfigOption(key: string): Promise { const config: any = await getConfig() + const defaults: any = defaultConfig - return config[key] || null + return config[key] || defaults[key] } export async function getConfig() {