Skip to content

Commit

Permalink
fix: resolve intermittent plugin startup issues
Browse files Browse the repository at this point in the history
  • Loading branch information
rxliuli committed Oct 8, 2024
1 parent 57be606 commit 7aaabbe
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/lib/plugins/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export interface PluginLoadResult {
}

export async function loadInstalledPlugins(): Promise<PluginLoadResult[]> {
const list = getStore(installedPlugins)
const list = await installedPlugins.getValue()
const plugins = (
await Promise.all(
list.map(async (it) => {
Expand Down
9 changes: 8 additions & 1 deletion src/lib/utils/localStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ export function localStore<T>(
key: string,
initial: T,
adapter: LocalStoreAdapter<T>,
): Writable<T> {
): Writable<T> & {
getValue(): Promise<T>
} {
const { subscribe, set, update } = writable(initial)
const r = adapter.read(key)
const init = (r: T | undefined | null) =>
Expand All @@ -29,6 +31,11 @@ export function localStore<T>(
return value
})
},
async getValue() {
const r = await adapter.read(key)
set(r)
return r
},
}
}

Expand Down
1 change: 1 addition & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,6 @@ export default defineConfig({
},
build: {
target: 'esnext',
sourcemap: true,
},
})

0 comments on commit 7aaabbe

Please sign in to comment.