Fix notification screen crashing in rare cases where the status no longer exists (#31403)

This commit is contained in:
Renaud Chaput authored and GitHub committed 2024-08-14 06:47:15 +00:00
1 parent 6bd7da72e9
commit 0d85a79f19
5 files changed
+15 -9

No files matched your search

@@ -37,7 +37,11 @@ export const NotificationMention: React.FC<{
unread: boolean;
}> = ({ notification, unread }) => {
const [isDirect, isReply] = useAppSelector((state) => {
const status = state.statuses.get(notification.statusId) as Status;
const status = state.statuses.get(notification.statusId) as
| Status
| undefined;
if (!status) return [false, false] as const;
return [
status.get('visibility') === 'direct',
@@ -23,7 +23,7 @@ export const NotificationWithStatus: React.FC<{
icon: IconProp;
iconId: string;
accountIds: string[];
statusId: string;
statusId: string | undefined;
count: number;
labelRenderer: LabelRenderer;
unread: boolean;
@@ -76,6 +76,8 @@ export const NotificationWithStatus: React.FC<{
[dispatch, statusId],
);
if (!statusId) return null;
return (
<HotKeys handlers={handlers}>
<div