diff --git a/lib/slax_web/live/chat_room_live.ex b/lib/slax_web/live/chat_room_live.ex index 94a8d67..85e4108 100644 --- a/lib/slax_web/live/chat_room_live.ex +++ b/lib/slax_web/live/chat_room_live.ex @@ -11,7 +11,13 @@ defmodule SlaxWeb.ChatRoomLive do

#<%= @room.name %>

-
<%= @room.topic %>
+
+ <%= if @hide_topic? do %> + [Topic hidden] + <% else %> + <%= @room.topic %> + <% end %> +
@@ -20,6 +26,10 @@ defmodule SlaxWeb.ChatRoomLive do def mount(_params, _session, socket) do room = Room |> Repo.all() |> List.first() - {:ok, assign(socket, :room, room)} + {:ok, assign(socket, hide_topic?: false, room: room)} + end + + def handle_event("toggle-topic", _params, socket) do + {:noreply, assign(socket, hide_topic?: !socket.assigns.hide_topic?)} end end