@@ -25,7 +25,7 @@ defmodule Phoenix.LiveView.LiveStream do
2525 # with manually calling stream_insert multiple times, as stream_insert prepends.
2626 items_list =
2727 for item <- items , reduce: [ ] do
28- items -> [ { dom_id . ( item ) , - 1 , item , opts [ :limit ] } | items ]
28+ items -> [ { dom_id . ( item ) , - 1 , item , opts [ :limit ] , opts [ :update_only ] } | items ]
2929 end
3030
3131 % LiveStream {
@@ -64,10 +64,10 @@ defmodule Phoenix.LiveView.LiveStream do
6464 % { stream | deletes: [ dom_id | stream . deletes ] }
6565 end
6666
67- def insert_item ( % LiveStream { } = stream , item , at , limit ) do
67+ def insert_item ( % LiveStream { } = stream , item , at , limit , update_only ) do
6868 item_id = stream . dom_id . ( item )
6969
70- % { stream | inserts: [ { item_id , at , item , limit } | stream . inserts ] }
70+ % { stream | inserts: [ { item_id , at , item , limit , update_only } | stream . inserts ] }
7171 end
7272
7373 defimpl Enumerable , for: LiveStream do
@@ -81,7 +81,7 @@ defmodule Phoenix.LiveView.LiveStream do
8181 # before rendering; we also remove duplicates to only use the most recent
8282 # inserts, which, as the items are reversed, are first
8383 { inserts , _ } =
84- for { id , _ , _ , _ } = insert <- stream . inserts , reduce: { [ ] , MapSet . new ( ) } do
84+ for { id , _ , _ , _ , _ } = insert <- stream . inserts , reduce: { [ ] , MapSet . new ( ) } do
8585 { inserts , ids } ->
8686 if MapSet . member? ( ids , id ) do
8787 # skip duplicates
@@ -106,7 +106,7 @@ defmodule Phoenix.LiveView.LiveStream do
106106 defp do_reduce ( list , { :suspend , acc } , fun ) , do: { :suspended , acc , & do_reduce ( list , & 1 , fun ) }
107107 defp do_reduce ( [ ] , { :cont , acc } , _fun ) , do: { :done , acc }
108108
109- defp do_reduce ( [ { dom_id , _at , item , _limit } | tail ] , { :cont , acc } , fun ) do
109+ defp do_reduce ( [ { dom_id , _at , item , _limit , _update_only } | tail ] , { :cont , acc } , fun ) do
110110 do_reduce ( tail , fun . ( { dom_id , item } , acc ) , fun )
111111 end
112112
0 commit comments