refactor(core): rename getCurrentValue to fetchCurrentValue

Also use Promise.allSettled in ContextBridge.refresh() to handle
provider errors gracefully.

Co-authored-by: Ona <no-reply@ona.com>
This commit is contained in:
2026-01-18 20:23:54 +00:00
parent 3c16dd4275
commit 037589cf4f
8 changed files with 41 additions and 19 deletions

View File

@@ -55,15 +55,21 @@ export class ContextBridge {
/**
* Gathers current values from all providers and pushes to controller.
* Use for manual refresh when user pulls to refresh.
* Errors from individual providers are silently ignored.
*/
async refresh(): Promise<void> {
const updates: Partial<Context> = {}
const entries = Array.from(this.providers.entries())
const values = await Promise.all(entries.map(([_, provider]) => provider.getCurrentValue()))
const results = await Promise.allSettled(
entries.map(([_, provider]) => provider.fetchCurrentValue()),
)
entries.forEach(([key], i) => {
updates[key] = values[i]
const result = results[i]
if (result?.status === "fulfilled") {
updates[key] = result.value
}
})
this.controller.pushContextUpdate(updates)