# fix\(usage\): coalesce account-switch refreshes and harden malformed config values · lucenx/codexbar-plasma

[View on GitCafe](https://git.cafe/lucenx/codexbar-plasma/commit/2230a0230ee8cd7421ab867b22d636ab03118381)

Repository: [lucenx/codexbar-plasma](https://git.cafe/lucenx/codexbar-plasma)

Visibility: public

Requested revision: 2230a0230ee8cd7421ab867b22d636ab03118381

Requested commit: 2230a0230ee8cd7421ab867b22d636ab03118381

Commit: 2230a0230ee8cd7421ab867b22d636ab03118381

Tree: d5d477378c0f7ccf3ae21bb3d6d804cbbcbc436a

Author: Simone

Committer: Simone

## Message

```
fix(usage): coalesce account-switch refreshes and harden malformed config values

selectAccount queued Qt.callLater(refreshNow) after writing selectedAccounts,
whose commandSource binding already fired scheduleUsageRefresh in
single-provider mode. Qt.callLater coalesces only identical function
references, so every account switch started one usage command and retired it
immediately in favour of a second. Both paths now use scheduleUsageRefresh,
which coalesces through the scheduled flag and still refreshes in
multi-provider mode where the command does not change.

Two untrusted-input guards relied on Number() coercion at their boundaries:
ProviderDescriptor.normalize accepted schemaVersion values that merely coerce
to 1 (true, "1", [1]), and QuotaThresholds.numericPercent turned whitespace,
arrays, and Infinity into a 1% warning threshold or a clamped maximum - the
exact corruption its comment says it prevents. Both now accept only the
documented shapes, matching the descriptor contract's unknown-schema rule.

Documentation impact: CHANGELOG Unreleased gained Fixed entries. Docs already
describe both contracts correctly; no README, usage guide, or TODO change is
needed, and no user-facing strings changed.

```

## Parents

- [d09e5b6dc0ffcb1eeb4625b9c0eb03a9b6598cb3](https://git.cafe/lucenx/codexbar-plasma/commit/d09e5b6dc0ffcb1eeb4625b9c0eb03a9b6598cb3?format=markdown)

[Source at this commit](https://git.cafe/lucenx/codexbar-plasma/tree/2230a0230ee8cd7421ab867b22d636ab03118381?format=markdown)
