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

[v16] Return early when rendering unsupported notification type #47421

Merged
merged 1 commit into from
Oct 17, 2024
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
9 changes: 6 additions & 3 deletions web/packages/teleport/src/Notifications/Notification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ export function Notification({
const { clusterId } = useStickyClusterId();

const content = ctx.notificationContentFactory(notification);
// If there is no notification content because it is an unsupported kind, don't render anything.
if (!content) {
return null;
}

const [markAsClickedAttempt, markAsClicked] = useAsync(() =>
ctx.notificationService
Expand Down Expand Up @@ -104,9 +108,8 @@ export function Notification({
// and don't redirect to any page.
const [showTextContentDialog, setShowTextContentDialog] = useState(false);

// If the notification is unsupported or hidden, or if the view is "Unread" and the notification has been read,
// it should not be shown.
if (!content || (view === 'Unread' && notification.clicked)) {
// If the view is "Unread" and the notification has been read, it should not be shown.
if (view === 'Unread' && notification.clicked) {
// If this is a text content notification, the dialog should still be renderable. This is to prevent the text content dialog immediately disappearing
// when trying to open an unread text notification, since clicking on the notification instantly marks it as read.
if (content.kind == 'text') {
Expand Down
Loading