mirror of
https://github.com/EnixCoda/Gitako.git
synced 2026-03-11 08:54:44 +00:00
fix: apply default config
This commit is contained in:
parent
3b08c474f0
commit
d857537f64
1 changed files with 4 additions and 4 deletions
|
|
@ -25,11 +25,13 @@ const defaultConfigs = {
|
|||
copySnippetButton: true,
|
||||
}
|
||||
|
||||
const configKeyArray = Object.values(configKeys)
|
||||
|
||||
function applyDefaultConfigs(configs: Config) {
|
||||
return Object.keys(configs).reduce(
|
||||
return configKeyArray.reduce(
|
||||
(applied, configKey) => {
|
||||
const key = configKey as keyof Config
|
||||
if (configs[key] === undefined) {
|
||||
if (!(key in configs)) {
|
||||
applied[key] = defaultConfigs[key]
|
||||
} else {
|
||||
applied[key] = configs[key]
|
||||
|
|
@ -40,8 +42,6 @@ function applyDefaultConfigs(configs: Config) {
|
|||
)
|
||||
}
|
||||
|
||||
const configKeyArray = Object.values(configKeys)
|
||||
|
||||
async function getAll(): Promise<Config> {
|
||||
return applyDefaultConfigs(await storageHelper.get(configKeyArray))
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue