 
   def handle_out("room:join" = ev, msg, socket) do
     %{room: room} = msg
-    warn ev, msg, "assigns: #{inspect socket.assigns}"
+    debug ev, msg, "assigns: #{inspect socket.assigns}"
     UserSocket.push_message_box(socket, socket.assigns.channel_id, socket.assigns.user_id)
     update_rooms_list(socket)
     {:noreply, subscribe([room], socket)}
   end
   def handle_out("room:leave" = ev, msg, socket) do
     %{room: room} = msg
-    warn ev, msg, "assigns: #{inspect socket.assigns}"
+    debug ev, msg, "assigns: #{inspect socket.assigns}"
     UserSocket.push_message_box(socket, socket.assigns.channel_id, socket.assigns.user_id)
     socket.endpoint.unsubscribe(CC.chan_room <> room)
     update_rooms_list(socket)
     {:noreply, assign(socket, :subscribed, List.delete(socket.assigns[:subscribed], room))}
   end
 
-  # def handle_out(ev <> "user:update", msg, socket) do
-  #   Logger.warn "user_channel: ev: #{inspect ev}, msg: #{inspect msg}"
-  #   {:noreply, socket}
-  # end
-
   ###############
   # Incoming Messages
 
   def handle_in("subscribe" = ev, params, socket) do
-    warn ev, params, "assigns: #{inspect socket.assigns}"
+    debug ev, params, "assigns: #{inspect socket.assigns}"
     {:noreply, socket}
   end
 
   def handle_in("flex:open:" <> tab = ev, params, socket) do
-    warn ev, params, "assigns: #{inspect socket.assigns}"
+    debug ev, params, "assigns: #{inspect socket.assigns}"
     {:noreply, toggle_flex(socket, tab, params)}
   end
   def handle_in("flex:item:open:" <> tab = ev, params, socket) do
-    warn ev, params, "assigns: #{inspect socket.assigns}"
+    debug ev, params, "assigns: #{inspect socket.assigns}"
     {:noreply, open_flex_item(socket, tab, params)}
   end
 
   def handle_in("flex:close" = ev, params, socket) do
-    warn ev, params
+    debug ev, params
     {:noreply, socket}
   end
 
   def handle_in("flex:view_all:" <> tab = ev, params, %{assigns: assigns} = socket) do
-    warn ev, params
+    debug ev, params
     fl = assigns[:flex] |> Flex.view_all(assigns[:channel_id], tab)
     {:noreply, assign(socket, :flex, fl)}
   end
 
   def handle_in("side_nav:open" = ev, %{"page" => "account"} = params, socket) do
-    warn ev, params
+    debug ev, params
 
     user = Helpers.get_user!(socket)
     account_cs = Account.changeset(user.account, %{})
-    #  $('.main-content').html(resp.html)
     html = Helpers.render(AccountView, "account_preferences.html", user: user, account_changeset: account_cs)
     push socket, "code:update", %{html: html, selector: ".main-content", action: "html"}
 

  end

  def handle_info({:flex, :open, ch, tab, nil, params} = msg, socket) do
    warn inspect(msg), "nil"
    resp = FlexBarService.handle_flex_callback(:open, ch, tab, nil, socket, params)
    push socket, "flex:open", Enum.into([title: tab], resp)
    {:noreply, socket}
  end
  def handle_info({:flex, :open, ch, tab, args, params} = msg, socket) do
    warn inspect(msg), "args"
    resp = FlexBarService.handle_flex_callback(:open, ch, tab, args[tab], socket, params)
    warn "resp: #{inspect resp}", ""
    push socket, "flex:open", Enum.into([title: tab], resp)
    {:noreply, socket}
  end
  def handle_info({:flex, :close, _ch, _tab, _, _params} = msg, socket) do
    warn inspect(msg), ""
    push socket, "flex:close", %{}
    {:noreply, socket}
  end

  require Logger

  def join_room(user_id, room) do
    # Logger.debug ("...join_room user_id: #{inspect user_id}")
    UcxChat.Endpoint.broadcast!(CC.chan_user() <> "#{user_id}", "room:join", %{room: room, user_id: user_id})
  end

