Skip to content

Commit

Permalink
Merge pull request #580 from podlove/fix-focus-lost
Browse files Browse the repository at this point in the history
filter ContentChangeEvents: process only events from other sockets
  • Loading branch information
electronicbites authored Oct 8, 2024
2 parents 0c43cd2 + 976c1e0 commit e7171e9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 6 additions & 0 deletions lib/radiator_web/live/outline_component.ex
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ defmodule RadiatorWeb.OutlineComponent do
|> reply(:ok)
end

def update(
%{event: %NodeContentChangedEvent{event_id: <<_::binary-size(36)>> <> ":" <> id}},
%{id: id} = socket
),
do: reply(socket, :ok)

def update(%{event: %NodeContentChangedEvent{node_id: node_id, content: content}}, socket) do
socket
|> push_event("set_content", %{uuid: node_id, content: content})
Expand Down
2 changes: 0 additions & 2 deletions test/radiator_web/live/outline_live_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ defmodule RadiatorWeb.OutlineLiveTest do

keep_liveview_alive()

assert_push_event(live, "set_content", %{uuid: ^uuid, content: "node_1_updated"})
assert_push_event(other_live, "set_content", %{uuid: ^uuid, content: "node_1_updated"})
end

Expand All @@ -90,7 +89,6 @@ defmodule RadiatorWeb.OutlineLiveTest do

keep_liveview_alive()

assert_push_event(live, "set_content", %{uuid: ^uuid, content: "no"})
assert_push_event(other_live, "set_content", %{uuid: ^uuid, content: "no"})

assert live |> has_element?("[value=de_2]")
Expand Down

0 comments on commit e7171e9

Please sign in to comment.