Skip to content

Commit

Permalink
fix devbox intiailization
Browse files Browse the repository at this point in the history
  • Loading branch information
kristiehuang committed Oct 10, 2023
1 parent 3f4df29 commit 42079dd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/components/FeatureFlagModal/FeatureFlagModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,13 @@ interface DynamicConfigDropdownProps {
label: string
options: any[]
selected: any[]
parser: (opt: string) => any
}

function DynamicConfigDropdown({ configName, label, options, selected }: DynamicConfigDropdownProps) {
function DynamicConfigDropdown({ configName, label, options, selected, parser }: DynamicConfigDropdownProps) {
const updateConfig = useUpdateConfig()
const handleSelectChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
const selectedValues = Array.from(e.target.selectedOptions, (opt) => Number.parseInt(opt.value))
const selectedValues = Array.from(e.target.selectedOptions, (opt) => parser(opt.value))
// Saved to atom as { [configName]: { [configName]: values } } to match Statsig return format
updateConfig(configName, { [configName]: selectedValues })
}
Expand Down Expand Up @@ -299,6 +300,7 @@ export default function FeatureFlagModal() {
<DynamicConfigDropdown
selected={useQuickRouteChains()}
options={Object.values(ChainId).filter((v) => !isNaN(Number(v))) as ChainId[]}
parser={Number.parseInt}
configName={DynamicConfigName.quickRouteChains}
label="Enable quick routes for these chains"
/>
Expand Down
8 changes: 4 additions & 4 deletions src/featureFlags/dynamicConfig/quickRouteChains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ export function useQuickRouteChains(): ChainId[] {
const featureFlagsContext = useFeatureFlagsContext()
let chains = statsigConfig.get(DynamicConfigName.quickRouteChains, []) as ChainId[]

const modalSetChains =
featureFlagsContext.configs[DynamicConfigName.quickRouteChains][DynamicConfigName.quickRouteChains]
if (Array.isArray(modalSetChains) && modalSetChains !== chains) {
chains = modalSetChains
const modalSettings = featureFlagsContext.configs[DynamicConfigName.quickRouteChains]
if (modalSettings) {
const modalSetChains = modalSettings[DynamicConfigName.quickRouteChains]
if (Array.isArray(modalSetChains) && modalSetChains !== chains) chains = modalSetChains
}
if (chains.every((c) => Object.values(ChainId).includes(c))) {
return chains
Expand Down

0 comments on commit 42079dd

Please sign in to comment.