mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 21:47:59 +01:00
pattern match result
This commit is contained in:
parent
0f75c973aa
commit
510abe5103
2 changed files with 9 additions and 10 deletions
|
@ -1,4 +1,4 @@
|
||||||
= if !!@object.user and !@object.anonymous do
|
= if !!@object.user and !@object.anonymous do
|
||||||
= anonymous_avatar(@object)
|
|
||||||
- else
|
|
||||||
= user_avatar(@object)
|
= user_avatar(@object)
|
||||||
|
- else
|
||||||
|
= anonymous_avatar(@object)
|
|
@ -16,15 +16,14 @@ defmodule PhilomenaWeb.UserAttributionView do
|
||||||
img_tag(Routes.static_path(PhilomenaWeb.Endpoint, "/images/no_avatar.svg"), class: class)
|
img_tag(Routes.static_path(PhilomenaWeb.Endpoint, "/images/no_avatar.svg"), class: class)
|
||||||
end
|
end
|
||||||
|
|
||||||
def user_avatar(object, class \\ "avatar--100px") do
|
def user_avatar(object, class \\ "avatar--100px")
|
||||||
user = object.user
|
|
||||||
|
|
||||||
if user && user.avatar do
|
def user_avatar(%{user: nil} = object, class),
|
||||||
img_tag(avatar_url_root() <> object.user.avatar, class: class)
|
do: anonymous_avatar(object, class)
|
||||||
else
|
def user_avatar(%{user: %{avatar: nil}} = object, class),
|
||||||
anonymous_avatar(object, class)
|
do: anonymous_avatar(object, class)
|
||||||
end
|
def user_avatar(%{user: %{avatar: avatar}}, class),
|
||||||
end
|
do: img_tag(avatar_url_root() <> avatar, class: class)
|
||||||
|
|
||||||
defp avatar_url_root do
|
defp avatar_url_root do
|
||||||
Application.get_env(:philomena, :avatar_url_root)
|
Application.get_env(:philomena, :avatar_url_root)
|
||||||
|
|
Loading…
Reference in a new issue