this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Adapt to new changes in group notifications API

Reference: https://github.com/mastodon/mastodon/pull/31214

+23 -4
+2 -2
src/pages/home.jsx
··· 12 12 import Notification from '../components/notification'; 13 13 import { api } from '../utils/api'; 14 14 import db from '../utils/db'; 15 - import groupNotifications from '../utils/group-notifications'; 15 + import { massageNotifications2 } from '../utils/group-notifications'; 16 16 import states, { saveStatus } from '../utils/states'; 17 17 import { getCurrentAccountNS } from '../utils/store-utils'; 18 18 ··· 98 98 99 99 async function fetchNotifications() { 100 100 const allNotifications = await notificationsIterator.next(); 101 - const notifications = allNotifications.value; 101 + const notifications = massageNotifications2(allNotifications.value); 102 102 103 103 if (notifications?.length) { 104 104 notifications.forEach((notification) => {
+2 -1
src/pages/notifications.jsx
··· 22 22 import enhanceContent from '../utils/enhance-content'; 23 23 import groupNotifications, { 24 24 groupNotifications2, 25 + massageNotifications2, 25 26 } from '../utils/group-notifications'; 26 27 import handleContentLinks from '../utils/handle-content-links'; 27 28 import mem from '../utils/mem'; ··· 120 121 }; 121 122 } 122 123 const allNotifications = await notificationsIterator.current.next(); 123 - const notifications = allNotifications.value; 124 + const notifications = massageNotifications2(allNotifications.value); 124 125 125 126 if (notifications?.length) { 126 127 notifications.forEach((notification) => {
+19 -1
src/utils/group-notifications.jsx
··· 28 28 }); 29 29 } 30 30 31 + export function massageNotifications2(notifications) { 32 + if (notifications?.accounts) { 33 + const { accounts, notificationGroups, statuses } = notifications; 34 + return notificationGroups.map((group) => { 35 + const { sampleAccountIds, statusId } = group; 36 + const sampleAccounts = 37 + sampleAccountIds?.map((id) => accounts.find((a) => a.id === id)) || []; 38 + const status = statuses?.find((s) => s.id === statusId) || null; 39 + return { 40 + ...group, 41 + sampleAccounts, 42 + status, 43 + }; 44 + }); 45 + } 46 + return notifications; 47 + } 48 + 31 49 export function groupNotifications2(groupNotifications) { 32 - // Massage grouped notifications to look like faux grouped notifications above 50 + // Make grouped notifications to look like faux grouped notifications 33 51 const newGroupNotifications = groupNotifications.map((gn) => { 34 52 const { 35 53 latestPageNotificationAt,