Skip to content

Commit

Permalink
Replace :saved event with :new and :edit events in pic_chat_messages …
Browse files Browse the repository at this point in the history
…reading
  • Loading branch information
phaleth committed Aug 14, 2023
1 parent fe5a874 commit 867c7e9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion reading/pic_chat_messages.livemd
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,14 @@ Elements are inserted into or removed from the stream.

```elixir
@impl true
def handle_info({PicChatWeb.MessageLive.FormComponent, {:saved, message}}, socket) do
def handle_info({PicChatWeb.MessageLive.FormComponent, {:new, message}}, socket) do
# prepends the new message
{:noreply, stream_insert(socket, :messages, message, at: 0)}
end

@impl true
def handle_info({PicChatWeb.MessageLive.FormComponent, {:edit, message}}, socket) do
# updates the new message in its current position
{:noreply, stream_insert(socket, :messages, message)}
end

Expand Down

0 comments on commit 867c7e9

Please sign in to comment.