ML-188: guard PubSub record updates during edit mode
Add live_action guard to handle_info({:update, record}) in both
CollectionLive.Show and WishlistLive.Show. When the user is editing,
background worker updates are skipped and a warning toast is shown
instead of overwriting the socket. Normal show-mode updates and
mismatched-ID no-ops are unchanged.
6 tests added covering all three code paths.
This commit is contained in:
@@ -119,6 +119,10 @@ defmodule MusicLibraryWeb.LiveHelpers.RecordActions do
|
||||
@doc """
|
||||
Handles a background record update. Returns the updated socket (not wrapped
|
||||
in `{:noreply, ...}`) so the caller can pipe additional assigns.
|
||||
|
||||
**Note:** Callers intentionally bypass this function when `live_action == :edit`
|
||||
to prevent background worker updates from overwriting the user's in-progress
|
||||
form edits. See CollectionLive.Show and WishlistLive.Show `handle_info({:update, record})`.
|
||||
"""
|
||||
def handle_record_updated(socket, record) do
|
||||
socket
|
||||
|
||||
Reference in New Issue
Block a user