feat(chat): show username using preload
This commit is contained in:
@@ -47,7 +47,7 @@ defmodule SlaxWeb.ChatRoomLive do
|
||||
<ul class="relative z-10 flex items-center gap-4 px-4 sm:px-6 lg:px-8 justify-end">
|
||||
<%= if @current_user do %>
|
||||
<li class="text-[0.8125rem] leading-6 text-zinc-900">
|
||||
<%= @current_user.email %>
|
||||
<%= username(@current_user) %>
|
||||
</li>
|
||||
<li>
|
||||
<.link
|
||||
@@ -157,7 +157,7 @@ defmodule SlaxWeb.ChatRoomLive do
|
||||
<div class="ml-2">
|
||||
<div class="-mt-1">
|
||||
<.link class="text-sm font-semibold hover:underline">
|
||||
<span>User</span>
|
||||
<span><%= username(@message.user) %></span>
|
||||
</.link>
|
||||
<p class="text-sm"><%= @message.body %></p>
|
||||
</div>
|
||||
@@ -165,4 +165,8 @@ defmodule SlaxWeb.ChatRoomLive do
|
||||
</div>
|
||||
"""
|
||||
end
|
||||
|
||||
defp username(user) do
|
||||
user.email |> String.split("@") |> List.first() |> String.capitalize()
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user