From bd3d791ee032acd61ad7e62bb10a88a6335dcc39 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Julius=20H=C3=A4rtl?= <jus@bitgrid.net>
Date: Fri, 31 Jul 2020 13:18:47 +0200
Subject: [PATCH] Only show display name if set
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Julius Härtl <jus@bitgrid.net>
---
 apps/dashboard/src/App.vue | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/apps/dashboard/src/App.vue b/apps/dashboard/src/App.vue
index 6680daea454..a87ce343706 100644
--- a/apps/dashboard/src/App.vue
+++ b/apps/dashboard/src/App.vue
@@ -74,7 +74,8 @@ export default {
 			timer: new Date(),
 			callbacks: {},
 			panels,
-			name: getCurrentUser()?.displayName,
+			displayName: getCurrentUser()?.displayName,
+			uid: getCurrentUser()?.uid,
 			layout: loadState('dashboard', 'layout').filter((panelId) => panels[panelId]),
 			modal: false,
 			appStoreUrl: generateUrl('/settings/apps'),
@@ -83,20 +84,21 @@ export default {
 	computed: {
 		greeting() {
 			const time = this.timer.getHours()
+			const shouldShowName = this.displayName && this.uid !== this.displayName
 
 			if (time > 18) {
-				return { icon: '🌙', text: t('dashboard', 'Good evening, {name}', { name: this.name }) }
+				return { icon: '🌙', text: shouldShowName ? t('dashboard', 'Good evening, {name}', { name: this.name }) : t('dashboard', 'Good evening') }
 			}
 			if (time > 12) {
-				return { icon: '☀', text: t('dashboard', 'Good afternoon, {name}', { name: this.name }) }
+				return { icon: '☀', text: shouldShowName ? t('dashboard', 'Good afternoon, {name}', { name: this.name }) : t('dashboard', 'Good afternoon') }
 			}
 			if (time === 12) {
-				return { icon: '🍽', text: t('dashboard', 'Time for lunch, {name}', { name: this.name }) }
+				return { icon: '🍽', text: shouldShowName ? t('dashboard', 'Time for lunch, {name}', { name: this.name }) : t('dashboard', 'Time for lunch') }
 			}
 			if (time > 5) {
-				return { icon: '🌄', text: t('dashboard', 'Good morning, {name}', { name: this.name }) }
+				return { icon: '🌄', text: shouldShowName ? t('dashboard', 'Good morning, {name}', { name: this.name }) : t('dashboard', 'Good morning') }
 			}
-			return { icon: '🦉', text: t('dashboard', 'Have a night owl, {name}', { name: this.name }) }
+			return { icon: '🦉', text: shouldShowName ? t('dashboard', 'Have a night owl, {name}', { name: this.name }) : t('dashboard', 'Have a night owl') }
 		},
 		isActive() {
 			return (panel) => this.layout.indexOf(panel.id) > -1
-- 
GitLab