Fix: avoid duplicate key names in notifications

zio/stable
Paul Frazee 2022-12-13 15:35:11 -06:00
parent 8af8d782c7
commit ac97667206
1 changed files with 3 additions and 2 deletions

View File

@ -11,6 +11,8 @@ const UNGROUPABLE_REASONS = ['trend', 'assertion']
const PAGE_SIZE = 30 const PAGE_SIZE = 30
const MS_60MIN = 1e3 * 60 * 60 const MS_60MIN = 1e3 * 60 * 60
let _idCounter = 0
export interface GroupedNotification extends ListNotifications.Notification { export interface GroupedNotification extends ListNotifications.Notification {
additional?: ListNotifications.Notification[] additional?: ListNotifications.Notification[]
} }
@ -361,13 +363,12 @@ export class NotificationsViewModel {
private async _appendAll(res: ListNotifications.Response, replace = false) { private async _appendAll(res: ListNotifications.Response, replace = false) {
this.loadMoreCursor = res.data.cursor this.loadMoreCursor = res.data.cursor
this.hasMore = !!this.loadMoreCursor this.hasMore = !!this.loadMoreCursor
let counter = this.notifications.length
const promises = [] const promises = []
const itemModels: NotificationsViewItemModel[] = [] const itemModels: NotificationsViewItemModel[] = []
for (const item of groupNotifications(res.data.notifications)) { for (const item of groupNotifications(res.data.notifications)) {
const itemModel = new NotificationsViewItemModel( const itemModel = new NotificationsViewItemModel(
this.rootStore, this.rootStore,
`item-${counter++}`, `item-${_idCounter++}`,
item, item,
) )
if (itemModel.needsAdditionalData) { if (itemModel.needsAdditionalData) {