Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(notifications): do not crash on missing notificationIcon #1118

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@ const NotificationBase = forwardRef<HTMLDivElement, NotificationBaseProps>((prop
markAsRead(props.id.toString());
};

if (!app) {
console.error('App was not found. Could not render notification.');
console.error(
'If you are using an external app, make sure it is started before NPWD and that you pass the correct app id to the notification.',
);
return null;
}

if (!app.NotificationIcon) {
console.warn('App does not have a notification icon');
}

return (
<StyledSnackbar onClick={handleNotisClick} ref={ref} style={{ minWidth: '370px' }}>
<Box display="flex" alignItems="center" color="white" width="100%" mb={0.7}>
Expand All @@ -56,7 +68,7 @@ const NotificationBase = forwardRef<HTMLDivElement, NotificationBaseProps>((prop
justifyContent="center"
alignItems="center"
>
<app.NotificationIcon fontSize="inherit" />
{app.NotificationIcon && <app.NotificationIcon fontSize="inherit" />}
</Box>
<Box color="#bfbfbf" fontWeight={400} paddingLeft={1} flexGrow={1} fontSize={16}>
{t(app.nameLocale)}
Expand Down
Loading