( notifications: GitifyNotification[], settings: SettingsState, )
| 150 | * @returns The same notifications with subject fields populated from the API. |
| 151 | */ |
| 152 | export async function enrichNotifications( |
| 153 | notifications: GitifyNotification[], |
| 154 | settings: SettingsState, |
| 155 | ): Promise<GitifyNotification[]> { |
| 156 | if (!settings.detailedNotifications) { |
| 157 | return notifications; |
| 158 | } |
| 159 | |
| 160 | const mergedResults = await fetchNotificationDetailsInBatches(notifications); |
| 161 | |
| 162 | const enrichedNotifications = await Promise.all( |
| 163 | notifications.map(async (notification: GitifyNotification) => { |
| 164 | const fragment = mergedResults.get(notification); |
| 165 | |
| 166 | return enrichNotification(notification, settings, fragment); |
| 167 | }), |
| 168 | ); |
| 169 | return enrichedNotifications; |
| 170 | } |
| 171 | |
| 172 | /** |
| 173 | * Fetch notification details in batches to avoid overwhelming the API. |
no test coverage detected