Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: dont use local storage for text config items #448

Conversation

SgtPooki
Copy link
Member

Title

fix: dont use local storage for text config items

Description

Loads config in config-context.tsx, and provides that in config.tsx, and updates save function to save text-input items from context-context to IDB

Fixes #447

Notes & open questions

See #446 for more changes coming.

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation if necessary (this includes comments as well)
  • I have added tests that prove my fix is effective or that my feature works

@SgtPooki SgtPooki linked an issue Nov 13, 2024 that may be closed by this pull request
@SgtPooki SgtPooki mentioned this pull request Nov 13, 2024
3 tasks
@SgtPooki SgtPooki requested a review from 2color November 13, 2024 22:59
@SgtPooki SgtPooki self-assigned this Nov 13, 2024
Copy link
Member Author

@SgtPooki SgtPooki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self review

@@ -76,13 +77,9 @@ const dnsJsonValidationFn = (value: string): Error | null => {
}
}

const stringValidationFn = (value: string): Error | null => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

validation function is optional, and we only use this for debug. removing and not passing validation function for debug input

Comment on lines +40 to +55
/**
* We need to make sure that the configDb types are loaded with the values from IDB
*/
useEffect(() => {
void (async () => {
const config = await getConfig(getUiComponentLogger('config-context'))
setGateways(config.gateways)
setRouters(config.routers)
setDnsJsonResolvers(config.dnsJsonResolvers)
setEnableWss(config.enableWss)
setEnableWebTransport(config.enableWebTransport)
setEnableGatewayProviders(config.enableGatewayProviders)
setEnableRecursiveGateways(config.enableRecursiveGateways)
setDebug(config.debug)
})()
}, [])
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be nice if we could do this faster..

Comment on lines +31 to +38
const [gateways, setGateways] = useState<string[]>([])
const [routers, setRouters] = useState<string[]>([])
const [dnsJsonResolvers, setDnsJsonResolvers] = useState<Record<string, string>>({})
const [enableWss, setEnableWss] = useState(false)
const [enableWebTransport, setEnableWebTransport] = useState(false)
const [enableGatewayProviders, setEnableGatewayProviders] = useState(false)
const [enableRecursiveGateways, setEnableRecursiveGateways] = useState(false)
const [debug, setDebug] = useState('')
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are set to the defaults in a later PR: #450 or #451

@SgtPooki SgtPooki merged commit aab3c00 into main Nov 14, 2024
16 checks passed
@SgtPooki SgtPooki deleted the 447-create-input-component-and-replace-local-storage-input-with-it branch November 14, 2024 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create input component and replace local-storage-input with it
1 participant