Add debug mode as a config setting

This commit is contained in:
KingRainbow44
2022-07-01 16:26:06 -04:00
parent 578d17764c
commit ec2f0f3ff8
2 changed files with 18 additions and 8 deletions

View File

@@ -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(
<React.StrictMode>
<App />
{
isDebug ? <Debug /> : <App />
}
</React.StrictMode>
)
// 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)
isDebug && reportWebVitals(console.log)

View File

@@ -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<void> {
@@ -52,8 +54,9 @@ export async function setConfigOption(key: string, value: any): Promise<void> {
export async function getConfigOption(key: string): Promise<any> {
const config: any = await getConfig()
const defaults: any = defaultConfig
return config[key] || null
return config[key] || defaults[key]
}
export async function getConfig() {