PhoenixKitWeb.CommentsForwarding (phoenix_kit v1.7.133)

Copy Markdown View Source

Forwards Leaf rich-text editor process messages to the optional phoenix_kit_comments package.

The embedded CommentsComponent's Leaf composer reports its content to the host LiveView via a {:leaf_changed, _} process message — LiveComponents can't receive handle_info themselves. The host must forward that message back into the component, or "Post Comment" silently posts empty content.

phoenix_kit_comments is an optional sibling dependency with no compile-order guarantee, so the call is resolved at runtime via apply/3 (never a compile-time-bound mod.fun(...) call) and degrades to a no-op when the package is absent.

Used by PhoenixKitWeb.Components.MediaBrowser.Embed (macro-injected handler) and PhoenixKitWeb.Live.Users.MediaDetail (inline handler) — both delegate their {:leaf_changed, _} handle_info clause here so the optional-dep contract lives in one place.

Summary

Functions

Forwards a {:leaf_changed, _} message to the comments component.

Functions

forward_leaf_changed(msg, socket)

Forwards a {:leaf_changed, _} message to the comments component.

Always returns {:noreply, socket}, so it can be used directly as the body of a host handle_info({:leaf_changed, _} = msg, socket) clause. When the comments package is absent (or its forward_leaf_event/2 contract drifts) the message is dropped gracefully — and contract drift is logged.