@@ -264,30 +264,33 @@ if Code.ensure_loaded?(Phoenix.Component) do
264264 end
265265 end
266266
267- # since we don't have control over the `mount` callback, but want to use
268- # `stream_configure` correctly which means that the stream should only be
269- # configured once, we do our own tracking of configured streams in the
270- # socket assigns
271267 defp configure_live_stream ( socket , name , query ) do
272- case socket . assigns do
273- % { __sync_stream_config__: % { ^ name => true } } ->
274- socket
275-
276- assigns ->
277- stream_opts =
278- if PredefinedShape . is_queryable? ( query ) ,
279- do: [ ] ,
280- else: [ dom_id: & Map . fetch! ( & 1 , :__sync_key__ ) ]
281-
282- assigns =
283- Map . update (
284- assigns ,
285- :__sync_stream_config__ ,
286- % { name => true } ,
287- & Map . put ( & 1 , name , true )
288- )
268+ if PredefinedShape . is_queryable? ( query ) do
269+ # if the shape is an Ecto.Struct then we can just fallback to the default
270+ # dom_id function (which is `value.id`)
271+ socket
272+ else
273+ # since we don't have control over the `mount` callback, but want to use
274+ # `stream_configure` correctly which means that the stream should only be
275+ # configured once, we do our own tracking of configured streams in the
276+ # socket assigns
277+ case socket . assigns do
278+ % { __sync_stream_config__: % { ^ name => true } } ->
279+ socket
280+
281+ assigns ->
282+ assigns =
283+ Map . update (
284+ assigns ,
285+ :__sync_stream_config__ ,
286+ % { name => true } ,
287+ & Map . put ( & 1 , name , true )
288+ )
289289
290- Phoenix.LiveView . stream_configure ( % { socket | assigns: assigns } , name , stream_opts )
290+ Phoenix.LiveView . stream_configure ( % { socket | assigns: assigns } , name ,
291+ dom_id: & Map . fetch! ( & 1 , :__sync_key__ )
292+ )
293+ end
291294 end
292295 end
293296
0 commit comments