attempt to fix dupliates in itemIdsToAdd
This commit is contained in:
parent
b8d1ccb339
commit
a2744cddb0
|
@ -4,6 +4,8 @@ import { database } from '../_database/database'
|
|||
import { mark, stop } from '../_utils/marks'
|
||||
import { store } from '../_store/store'
|
||||
import { scheduleIdleTask } from '../_utils/scheduleIdleTask'
|
||||
import uniqBy from 'lodash/uniqBy'
|
||||
import uniq from 'lodash/uniq'
|
||||
|
||||
async function getExistingItemIdsSet (instanceName, timelineName) {
|
||||
let timelineItemIds = store.getForTimeline(instanceName, timelineName, 'timelineItemIds') || []
|
||||
|
@ -28,6 +30,7 @@ async function insertUpdatesIntoTimeline (instanceName, timelineName, updates) {
|
|||
let itemIdsToAdd = store.getForTimeline(instanceName, timelineName, 'itemIdsToAdd') || []
|
||||
if (updates && updates.length) {
|
||||
itemIdsToAdd = itemIdsToAdd.concat(updates.map(_ => _.id))
|
||||
itemIdsToAdd = uniq(itemIdsToAdd)
|
||||
console.log('adding ', itemIdsToAdd.length, 'items to itemIdsToAdd')
|
||||
store.setForTimeline(instanceName, timelineName, {itemIdsToAdd: itemIdsToAdd})
|
||||
}
|
||||
|
@ -78,6 +81,7 @@ const lazilyProcessFreshUpdates = throttle((instanceName, timelineName) => {
|
|||
export function addStatusOrNotification (instanceName, timelineName, newStatusOrNotification) {
|
||||
let freshUpdates = store.getForTimeline(instanceName, timelineName, 'freshUpdates') || []
|
||||
freshUpdates.push(newStatusOrNotification)
|
||||
freshUpdates = uniqBy(freshUpdates, 'id')
|
||||
store.setForTimeline(instanceName, timelineName, {freshUpdates: freshUpdates})
|
||||
lazilyProcessFreshUpdates(instanceName, timelineName)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue