Skip to content

Commit

Permalink
fix(theme): improve local icons load
Browse files Browse the repository at this point in the history
  • Loading branch information
pengzhanbo committed Aug 12, 2024
1 parent f69490a commit 4a49b9f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
6 changes: 3 additions & 3 deletions theme/src/node/loadConfig/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export async function onConfigChange(onChange: ChangeEvent) {
if (loader && !loader.changeEvents.includes(onChange)) {
loader.changeEvents.push(onChange)
if (loader.loaded) {
onChange(loader.resolvedConfig)
await onChange(loader.resolvedConfig)
}
}
}
Expand Down Expand Up @@ -140,9 +140,9 @@ function updateResolvedConfig(app: App, userConfig: ThemeConfig = {}) {
}
}

function runChangeEvents() {
async function runChangeEvents() {
if (loader) {
loader.changeEvents.forEach(fn => fn(loader!.resolvedConfig))
await Promise.all(loader.changeEvents.map(fn => fn(loader!.resolvedConfig)))
}
}

Expand Down
10 changes: 6 additions & 4 deletions theme/src/node/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,13 @@ export function plumeTheme(options: PlumeThemeOptions = {}): Theme {
},

onPrepared: async (app) => {
onConfigChange(({ localeOptions }) => {
prepareThemeData(app, localeOptions)
prepareData(app)
onConfigChange(async ({ localeOptions }) => {
await prepareThemeData(app, localeOptions)
await prepareData(app)
})
await waitForConfigLoaded()
const { localeOptions } = await waitForConfigLoaded()
await prepareThemeData(app, localeOptions)
await prepareData(app)
},

onWatched: (app, watchers) => {
Expand Down

0 comments on commit 4a49b9f

Please sign in to comment.