From 1651d52c1845f70dce3701a8786edb1741b3aa02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20N=C3=BDvlt?= Date: Fri, 9 Aug 2024 11:36:32 +0200 Subject: [PATCH] Use username as fallback --- lib/chore_tracker/accounts.ex | 4 ++++ lib/chore_tracker_web/components/layouts.ex | 3 ++- lib/chore_tracker_web/live/chore_live/form_component.ex | 2 +- lib/chore_tracker_web/live/chore_live/show.ex | 2 ++ lib/chore_tracker_web/live/chore_live/show.html.heex | 4 ++-- lib/chore_tracker_web/live/overview_live.ex | 2 +- 6 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/chore_tracker/accounts.ex b/lib/chore_tracker/accounts.ex index bd63cff..408cffc 100644 --- a/lib/chore_tracker/accounts.ex +++ b/lib/chore_tracker/accounts.ex @@ -376,4 +376,8 @@ defmodule ChoreTracker.Accounts do {:error, :user, changeset, _} -> {:error, changeset} end end + + def display_user(%User{} = user) do + user.display_name || user.username + end end diff --git a/lib/chore_tracker_web/components/layouts.ex b/lib/chore_tracker_web/components/layouts.ex index 6fac65f..2363c58 100644 --- a/lib/chore_tracker_web/components/layouts.ex +++ b/lib/chore_tracker_web/components/layouts.ex @@ -1,5 +1,6 @@ defmodule ChoreTrackerWeb.Layouts do use ChoreTrackerWeb, :html + alias ChoreTracker.Accounts embed_templates "layouts/*" @@ -9,7 +10,7 @@ defmodule ChoreTrackerWeb.Layouts do