Normalize 'group_mention' notification into 'mention'
This commit is contained in:
parent
e0056d4931
commit
cb6b688efe
2 changed files with 15 additions and 3 deletions
|
@ -25,8 +25,19 @@ export const NotificationRecord = ImmutableRecord({
|
|||
total_count: null as number | null, // grouped notifications
|
||||
});
|
||||
|
||||
const normalizeType = (notification: ImmutableMap<string, any>) => {
|
||||
if (notification.get('type') === 'group_mention') {
|
||||
return notification.set('type', 'mention');
|
||||
}
|
||||
|
||||
return notification;
|
||||
};
|
||||
|
||||
export const normalizeNotification = (notification: Record<string, any>) => {
|
||||
return NotificationRecord(
|
||||
ImmutableMap(fromJS(notification)),
|
||||
ImmutableMap(fromJS(notification))
|
||||
.withMutations((notification: ImmutableMap<string, any>) => {
|
||||
normalizeType(notification);
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
|
|
@ -88,12 +88,12 @@ const isValid = (notification: APIEntity) => {
|
|||
}
|
||||
|
||||
// https://gitlab.com/soapbox-pub/soapbox/-/issues/424
|
||||
if (!notification.account.id) {
|
||||
if (!notification.account.get('id')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Mastodon can return status notifications with a null status
|
||||
if (['mention', 'reblog', 'favourite', 'poll', 'status'].includes(notification.type) && !notification.status.id) {
|
||||
if (['mention', 'reblog', 'favourite', 'poll', 'status'].includes(notification.type) && !notification.status.get('id')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -131,6 +131,7 @@ const importNotification = (state: State, notification: APIEntity) => {
|
|||
export const processRawNotifications = (notifications: APIEntity[]) => (
|
||||
ImmutableOrderedMap(
|
||||
notifications
|
||||
.map(normalizeNotification)
|
||||
.filter(isValid)
|
||||
.map(n => [n.id, fixNotification(n)]),
|
||||
));
|
||||
|
|
Loading…
Reference in a new issue