From 943d817e71e827171d401ba2d2b0c8eb3733f934 Mon Sep 17 00:00:00 2001 From: David Ralph Date: Wed, 11 Aug 2021 16:21:35 +0100 Subject: [PATCH] perf: optimise greeting --- src/components/widgets/greeting/Greeting.jsx | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/components/widgets/greeting/Greeting.jsx b/src/components/widgets/greeting/Greeting.jsx index a3ecb789..175aae6e 100644 --- a/src/components/widgets/greeting/Greeting.jsx +++ b/src/components/widgets/greeting/Greeting.jsx @@ -89,13 +89,16 @@ export default class Greeting extends React.PureComponent { } // Birthday - const birth = new Date(localStorage.getItem('birthday')); - if (localStorage.getItem('birthdayenabled') === 'true' && birth.getDate() === now.getDate() && birth.getMonth() === now.getMonth()) { - if (localStorage.getItem('birthdayage') === 'true') { - const text = this.language.birthday.split(' '); - message = `${text[0]} ${dtf.nth(this.calculateAge(birth))} ${text[1]}`; - } else { - message = this.language.birthday; + if (localStorage.getItem('birthdayenabled') === 'true') { + const birth = new Date(localStorage.getItem('birthday')); + + if (birth.getDate() === now.getDate() && birth.getMonth() === now.getMonth()) { + if (localStorage.getItem('birthdayage') === 'true') { + const text = this.language.birthday.split(' '); + message = `${text[0]} ${dtf.nth(this.calculateAge(birth))} ${text[1]}`; + } else { + message = this.language.birthday; + } } }