mirror of
https://github.com/spartanz51/tutabridge.git
synced 2026-06-24 10:54:32 +02:00
91487874978a325427fceaaefc40f0d19e5bac34
Phase 2.5 — `prefetch_loop` no longer wakes every 30s. It subscribes to `MailStore::subscribe()` and only catches up missing bodies when the generation counter ticks (event-bus delta, sync_folder finishing, bootstrap). When the store is quiet — every cached mail has its .eml on disk — the loop sleeps indefinitely on the watch channel. The `PREFETCH_INTERVAL` constant is gone. Phase 2.6 — the dashboard 1s `setInterval` is gone too. `BridgeHandle` gets a `stats_dirty_tx: broadcast::Sender<()>` that pulses on every `MailStore` bump, every `WsState` transition, and the start / stop status transitions. A small watcher task inside `start()` plumbs the two `watch::Receiver`s into the broadcast. The Tauri layer (`stream_stats`) subscribes via `BridgeHandle::subscribe_stats()`, takes a stats + status snapshot on every pulse (and once at startup), and emits two events `bridge://stats` / `bridge://status` to the webview. The React hook replaces `setInterval(refresh, 1000)` with two `listen()` subscriptions; the initial `refresh()` still seeds the state for the first frame. Backend now has zero `time::sleep`-driven polling loops: the syncer is driven by Phase 0 + bootstrap + the event bus, prefetch is driven by store changes, and the UI is driven by pushes. The only remaining delays are throttling (`INTER_FOLDER_DELAY`, `INTER_REQUEST_DELAY`) and reconnect backoff, which are not polls. 166 bridge lib tests, full workspace builds, UI tsc clean.
Languages
Rust
89.5%
TypeScript
5.9%
CSS
2.5%
Python
1.2%
Shell
0.7%
Other
0.1%