ML-168: broadcast index_changed event after background import
Import workers now broadcast :records_index_changed on "records:index_changed" after successful import via Records.broadcast_index_changed/0. CollectionLive.Index and WishlistLive.Index subscribe to the topic in mount/3 and reload their record streams on receipt, with a live_action guard to skip reloads when the grid is hidden behind a modal (:import, :barcode_scan). IndexActions.handle_index_changed/1 refreshes total_entries before reloading to keep the pagination bar accurate.
This commit is contained in:
@@ -250,10 +250,11 @@ HTTP 429 into `:rate_limit` vs `:auth_error` by reading the body `code`
|
||||
|
||||
## PubSub Topics
|
||||
|
||||
| PubSub | Topic Pattern | Message | Used By |
|
||||
| ---------------- | -------------------------- | ------------------- | ---------------------------------------------------------------------------------------------- |
|
||||
| `:music_library` | `"records:#{id}"` | `{:update, record}` | CollectionLive.Show, WishlistLive.Show — subscribe in handle_params, unsubscribe on navigation |
|
||||
| `:music_library` | `"listening_stats:update"` | `%{track_count: n}` | StatsLive.Index, ScrobbledTracksLive.Index — new scrobbles arrived |
|
||||
| PubSub | Topic Pattern | Message | Used By |
|
||||
| ---------------- | -------------------------- | ------------------------ | ---------------------------------------------------------------------------------------------- |
|
||||
| `:music_library` | `"records:#{id}"` | `{:update, record}` | CollectionLive.Show, WishlistLive.Show — subscribe in handle_params, unsubscribe on navigation |
|
||||
| `:music_library` | `"records:index_changed"` | `:records_index_changed` | CollectionLive.Index, WishlistLive.Index — auto-refresh when background import completes |
|
||||
| `:music_library` | `"listening_stats:update"` | `%{track_count: n}` | StatsLive.Index, ScrobbledTracksLive.Index — new scrobbles arrived |
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user