* Ensure `updateChargeStatsDisplay` reliably updates charges and full charge display.
* Fix interval handling: clear previous intervals and reset variable to `null`.
* Inline full charge display logic, defaulting to `--:--:--` when not available.
Benefits:
* Charge stats now update consistently without missing ticks.
* Interval management is safer, preventing multiple overlapping timers.
Note:
* Full stats partial update logic is now fully integrated; previous issue of UI flicker or missed updates is resolved.
- Replace `currentCharges` with `displayCharges` for UI representation.
- Introduce `preciseCurrentCharges` to track fractional charge values.
- Update logic in `resetEdgeTracking`, `maybeNotifyChargesReached`, and related functions to use `displayCharges`.
- Modify `updateFullChargeDisplay` to calculate and use `preciseCurrentCharges` and `displayCharges`.
- Refactor `getRemainingMsToThreshold` into `getMsToTargetCharges` for clarity and precision.
- Replace `startChargesThresholdTicker` and `updateChargesThresholdUI` with a unified `updateChargesThresholdUI` function.
- Update HTML templates and dynamic UI updates to reflect `displayCharges`.
Benefits:
- Improves accuracy by distinguishing between displayed and precise charge values.
- Simplifies charge-related logic and reduces redundant calculations.
- Enhances readability and maintainability of charge tracking and UI updates.
Note:
- Ensure all dependent modules correctly handle the new `displayCharges` and `preciseCurrentCharges` fields.
- Introduce conditions to determine whether to call the API based on forced refresh, first check, or elapsed time.
- Add randomization for update intervals between 60s and 90s to stagger API requests.
- Preserve existing behavior of updating charges, cooldown, and max charges when API is called.
- Clear and reset the interval for `updateFullChargeDisplay` only when necessary.
Benefits:
- Reduces server load by avoiding frequent unnecessary API calls.
- Improves efficiency by introducing randomized update intervals.
- Maintains backward compatibility with existing functionality.
Note:
- Ensure `WPlaceService.getCharges()` continues to return valid data under new conditions.
- Replace `wplace-random-batch-input` and `wplace-block-size-input` classes with `wplace-settings-number-input`.
- Update CSS to consolidate styles under `wplace-settings-number-input`.
- Refactor theme variables for background and border colors to use explicit hex values, fixing visibility issue in light theme.
- Remove redundant `.wplace-block-size-input` styles.
Benefits:
- Number inputs are now correctly visible in all themes, including light.
- Reduces duplication in CSS by consolidating input styles.
- Improves consistency across input elements in the UI.
- Enhances clarity of theme variable usage with explicit naming.
Note:
- Ensure all components previously using `wplace-random-batch-input` or `wplace-block-size-input` are tested for visual consistency.