mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-24 04:27: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
|
||||
= anonymous_avatar(@object)
|
||||
- else
|
||||
= 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)
|
||||
end
|
||||
|
||||
def user_avatar(object, class \\ "avatar--100px") do
|
||||
user = object.user
|
||||
def user_avatar(object, class \\ "avatar--100px")
|
||||
|
||||
if user && user.avatar do
|
||||
img_tag(avatar_url_root() <> object.user.avatar, class: class)
|
||||
else
|
||||
anonymous_avatar(object, class)
|
||||
end
|
||||
end
|
||||
def user_avatar(%{user: nil} = object, class),
|
||||
do: anonymous_avatar(object, class)
|
||||
def user_avatar(%{user: %{avatar: nil}} = object, class),
|
||||
do: anonymous_avatar(object, class)
|
||||
def user_avatar(%{user: %{avatar: avatar}}, class),
|
||||
do: img_tag(avatar_url_root() <> avatar, class: class)
|
||||
|
||||
defp avatar_url_root do
|
||||
Application.get_env(:philomena, :avatar_url_root)
|
||||
|
|
Loading…
Reference in a new issue