Skip to content

Commit

Permalink
remove notifications for now
Browse files Browse the repository at this point in the history
will be moved to evebt_consumer (or so)
  • Loading branch information
electronicbites committed Mar 30, 2024
1 parent da2cbb7 commit 3bbb94d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 18 deletions.
13 changes: 4 additions & 9 deletions lib/radiator/outline.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,16 @@ defmodule Radiator.Outline do
import Ecto.Query, warn: false

alias Radiator.Outline.Node
alias Radiator.Outline.Notify
alias Radiator.Repo

def create(attrs \\ %{}, socket_id \\ nil) do
def create(attrs \\ %{}, _socket_id \\ nil) do
attrs
|> create_node()
|> Notify.broadcast_node_action(:insert, socket_id)
end

def delete(%Node{} = node, socket_id \\ nil) do
def delete(%Node{} = node, _socket_id \\ nil) do
node
|> delete_node()
|> Notify.broadcast_node_action(:delete, socket_id)
end

@doc """
Expand Down Expand Up @@ -232,11 +229,10 @@ defmodule Radiator.Outline do
{:error, %Ecto.Changeset{}}
"""
def create_node(attrs \\ %{}, socket_id \\ nil) do
def create_node(attrs \\ %{}, _socket_id \\ nil) do
%Node{}
|> Node.insert_changeset(attrs)
|> Repo.insert()
|> Notify.broadcast_node_action(:insert, socket_id)
end

@doc """
Expand Down Expand Up @@ -319,11 +315,10 @@ defmodule Radiator.Outline do
{:error, %Ecto.Changeset{}}
"""
def update_node_content(%Node{} = node, attrs, socket_id \\ nil) do
def update_node_content(%Node{} = node, attrs, _socket_id \\ nil) do
node
|> Node.update_content_changeset(attrs)
|> Repo.update()
|> Notify.broadcast_node_action(:update, socket_id)
end

@doc """
Expand Down
16 changes: 7 additions & 9 deletions test/radiator_web/live/episode_live_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ defmodule RadiatorWeb.EpisodeLiveTest do

test "insert a new node", %{conn: conn, show: show} do
{:ok, live, _html} = live(conn, ~p"/admin/podcast/#{show.id}")
{:ok, other_live, _html} = live(conn, ~p"/admin/podcast/#{show.id}")
{:ok, _other_live, _html} = live(conn, ~p"/admin/podcast/#{show.id}")

temp_id = "f894d2ed-9447-4eef-8c31-fc52372b3bbe"
params = %{"temp_id" => temp_id, "content" => "new node temp content"}
Expand All @@ -82,12 +82,12 @@ defmodule RadiatorWeb.EpisodeLiveTest do

assert_reply(live, ^node_with_temp_id)

assert_push_event(other_live, "insert", ^node)
# FIXME: assert_push_event(other_live, "insert", ^node)
end

test "update node", %{conn: conn, show: show, episode: episode} do
{:ok, live, _html} = live(conn, ~p"/admin/podcast/#{show.id}")
{:ok, other_live, _html} = live(conn, ~p"/admin/podcast/#{show.id}")
{:ok, _other_live, _html} = live(conn, ~p"/admin/podcast/#{show.id}")

node = node_fixture(%{episode_id: episode.id})

Expand All @@ -104,22 +104,20 @@ defmodule RadiatorWeb.EpisodeLiveTest do

assert updated_node.uuid == params.uuid
assert updated_node.content == params.content

assert_push_event(other_live, "update", ^updated_node)
# FIXME: assert_push_event(other_live, "update", ^updated_node)
end

test "delete node", %{conn: conn, show: show, episode: episode} do
{:ok, live, _html} = live(conn, ~p"/admin/podcast/#{show.id}")
{:ok, other_live, _html} = live(conn, ~p"/admin/podcast/#{show.id}")
{:ok, _other_live, _html} = live(conn, ~p"/admin/podcast/#{show.id}")

node = node_fixture(%{episode_id: episode.id})
params = Map.from_struct(node)

assert live |> render_hook(:delete_node, params)

assert_push_event(other_live, "delete", %{uuid: deleted_uuid})

assert deleted_uuid == node.uuid
# FIXME: assert_push_event(other_live, "delete", %{uuid: deleted_uuid})
# FIXME: assert deleted_uuid == node.uuid
end
end
end

0 comments on commit 3bbb94d

Please sign in to comment.