mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-11-24 02:05:39 +03:00
Allowlist groupable notifications
This commit is contained in:
parent
35fa94b2e0
commit
a1a4b01ace
1 changed files with 10 additions and 4 deletions
|
@ -9,6 +9,10 @@ const notificationTypeKeys = {
|
||||||
poll: ['status'],
|
poll: ['status'],
|
||||||
update: ['status'],
|
update: ['status'],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const GROUP_TYPES = ['favourite', 'reblog', 'follow'];
|
||||||
|
const groupable = (type) => GROUP_TYPES.includes(type);
|
||||||
|
|
||||||
export function fixNotifications(notifications) {
|
export function fixNotifications(notifications) {
|
||||||
return notifications.filter((notification) => {
|
return notifications.filter((notification) => {
|
||||||
const { type, id, createdAt } = notification;
|
const { type, id, createdAt } = notification;
|
||||||
|
@ -85,7 +89,7 @@ export function groupNotifications2(groupNotifications) {
|
||||||
} = gn;
|
} = gn;
|
||||||
const date = createdAt ? new Date(createdAt).toLocaleDateString() : '';
|
const date = createdAt ? new Date(createdAt).toLocaleDateString() : '';
|
||||||
let virtualType = type;
|
let virtualType = type;
|
||||||
const sameCount =
|
// const sameCount =
|
||||||
notificationsCount > 0 && notificationsCount === sampleAccounts?.length;
|
notificationsCount > 0 && notificationsCount === sampleAccounts?.length;
|
||||||
// if (sameCount && (type === 'favourite' || type === 'reblog')) {
|
// if (sameCount && (type === 'favourite' || type === 'reblog')) {
|
||||||
if (type === 'favourite' || type === 'reblog') {
|
if (type === 'favourite' || type === 'reblog') {
|
||||||
|
@ -94,7 +98,9 @@ export function groupNotifications2(groupNotifications) {
|
||||||
// const key = `${status?.id}-${virtualType}-${date}-${sameCount ? 1 : 0}`;
|
// const key = `${status?.id}-${virtualType}-${date}-${sameCount ? 1 : 0}`;
|
||||||
const key = `${status?.id}-${virtualType}-${date}`;
|
const key = `${status?.id}-${virtualType}-${date}`;
|
||||||
const mappedNotification = notificationsMap[key];
|
const mappedNotification = notificationsMap[key];
|
||||||
if (mappedNotification) {
|
if (!groupable(type)) {
|
||||||
|
newGroupNotifications1.push(gn);
|
||||||
|
} else if (mappedNotification) {
|
||||||
// Merge sampleAccounts + merge _types
|
// Merge sampleAccounts + merge _types
|
||||||
sampleAccounts.forEach((a) => {
|
sampleAccounts.forEach((a) => {
|
||||||
const mappedAccount = mappedNotification.sampleAccounts.find(
|
const mappedAccount = mappedNotification.sampleAccounts.find(
|
||||||
|
@ -199,7 +205,7 @@ export default function groupNotifications(notifications) {
|
||||||
}
|
}
|
||||||
const key = `${status?.id}-${virtualType}-${date}`;
|
const key = `${status?.id}-${virtualType}-${date}`;
|
||||||
const mappedNotification = notificationsMap[key];
|
const mappedNotification = notificationsMap[key];
|
||||||
if (virtualType === 'follow_request') {
|
if (!groupable(type)) {
|
||||||
cleanNotifications[j++] = notification;
|
cleanNotifications[j++] = notification;
|
||||||
} else if (mappedNotification?.account) {
|
} else if (mappedNotification?.account) {
|
||||||
const mappedAccount = mappedNotification._accounts.find(
|
const mappedAccount = mappedNotification._accounts.find(
|
||||||
|
|
Loading…
Reference in a new issue