mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-26 15:31:52 +00:00
Fix web UI crash when a encoutering an orphaned notification group
Fixes #31392
This commit is contained in:
parent
b42661ba95
commit
4c996964c7
|
@ -20,6 +20,21 @@ import { NotificationSeveredRelationships } from './notification_severed_relatio
|
|||
import { NotificationStatus } from './notification_status';
|
||||
import { NotificationUpdate } from './notification_update';
|
||||
|
||||
function missingActivity(notificationGroup: NotificationGroupModel) {
|
||||
switch (notificationGroup.type) {
|
||||
case 'reblog':
|
||||
case 'favourite':
|
||||
case 'mention':
|
||||
case 'update':
|
||||
case 'status':
|
||||
case 'poll':
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- our type is actually not correct as the server can occasionally have orphaned notifications
|
||||
return notificationGroup.statusId === null;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export const NotificationGroup: React.FC<{
|
||||
notificationGroupId: NotificationGroupModel['group_key'];
|
||||
unread: boolean;
|
||||
|
@ -60,7 +75,12 @@ export const NotificationGroup: React.FC<{
|
|||
[dispatch, notificationGroupId, accountId, onMoveUp, onMoveDown],
|
||||
);
|
||||
|
||||
if (!notificationGroup || notificationGroup.type === 'gap') return null;
|
||||
if (
|
||||
!notificationGroup ||
|
||||
notificationGroup.type === 'gap' ||
|
||||
missingActivity(notificationGroup)
|
||||
)
|
||||
return null;
|
||||
|
||||
let content;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user