Fixed missing greeting when no custom messages present
This commit is contained in:
@@ -39,7 +39,7 @@ export function Homepage() {
|
|||||||
} = useCommonHooks();
|
} = useCommonHooks();
|
||||||
const [personal, setPersonal] = useState<PersonalData>();
|
const [personal, setPersonal] = useState<PersonalData>();
|
||||||
const [message, setMessage] = useState<Message>();
|
const [message, setMessage] = useState<Message>();
|
||||||
const [displayedGreeting, setDisplayedGreeting] = useState('');
|
const [displayedGreeting, setDisplayedGreeting] = useState<string | undefined>('');
|
||||||
const [weatherModalOpened, { open: openWeatherModal, close: closeWeatherModal }] =
|
const [weatherModalOpened, { open: openWeatherModal, close: closeWeatherModal }] =
|
||||||
useDisclosure(false);
|
useDisclosure(false);
|
||||||
const dateOptions: Intl.DateTimeFormatOptions = !isMobile
|
const dateOptions: Intl.DateTimeFormatOptions = !isMobile
|
||||||
@@ -63,7 +63,7 @@ export function Homepage() {
|
|||||||
}
|
}
|
||||||
}, [personalData, personalIsFetched]);
|
}, [personalData, personalIsFetched]);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (message !== undefined && personal) {
|
if (personal) {
|
||||||
setDisplayedGreeting(() => {
|
setDisplayedGreeting(() => {
|
||||||
if (Math.floor(Math.random() * 100) > 10 || message === undefined) {
|
if (Math.floor(Math.random() * 100) > 10 || message === undefined) {
|
||||||
switch (Math.floor(new Date().getHours() / 6)) {
|
switch (Math.floor(new Date().getHours() / 6)) {
|
||||||
@@ -77,7 +77,7 @@ export function Homepage() {
|
|||||||
return `Good evening, ${personal?.firstName}!`;
|
return `Good evening, ${personal?.firstName}!`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return message.message;
|
return message?.message;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [message, personal, isMessagesFetching]);
|
}, [message, personal, isMessagesFetching]);
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ function Header({
|
|||||||
basicWeather,
|
basicWeather,
|
||||||
openWeatherModal,
|
openWeatherModal,
|
||||||
}: {
|
}: {
|
||||||
greet: string;
|
greet: string | undefined;
|
||||||
date: string;
|
date: string;
|
||||||
current: CurrentWeather;
|
current: CurrentWeather;
|
||||||
setCurrent: (current: CurrentWeather) => void;
|
setCurrent: (current: CurrentWeather) => void;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ function LargeHeader({
|
|||||||
weather,
|
weather,
|
||||||
basicWeather,
|
basicWeather,
|
||||||
}: {
|
}: {
|
||||||
greet: string;
|
greet: string | undefined;
|
||||||
date: string;
|
date: string;
|
||||||
weather: any;
|
weather: any;
|
||||||
basicWeather: any;
|
basicWeather: any;
|
||||||
@@ -73,7 +73,7 @@ function LargeHeader({
|
|||||||
fz={isMobile ? '2rem' : '6rem'}
|
fz={isMobile ? '2rem' : '6rem'}
|
||||||
>
|
>
|
||||||
{greet
|
{greet
|
||||||
.replace('$firstName', currentUser.firstName)
|
?.replace('$firstName', currentUser.firstName)
|
||||||
.replace('$lastName', currentUser.lastName)
|
.replace('$lastName', currentUser.lastName)
|
||||||
.replace('$^firstName', currentUser.firstName.toUpperCase())
|
.replace('$^firstName', currentUser.firstName.toUpperCase())
|
||||||
.replace('$^lastName', currentUser.lastName.toUpperCase())}
|
.replace('$^lastName', currentUser.lastName.toUpperCase())}
|
||||||
|
|||||||
Reference in New Issue
Block a user