diff --git a/src/Pim.tsx b/src/Pim.tsx index 20a4946..3f9d735 100644 --- a/src/Pim.tsx +++ b/src/Pim.tsx @@ -51,10 +51,10 @@ const itemsSelector = createSelector( const collectionInfo = syncJournal.collection; if (collectionInfo.type === 'ADDRESS_BOOK') { - addressBookItems = Object.assign(addressBookItems, syncEntriesToItemMap(collectionInfo, syncEntries)); + addressBookItems = syncEntriesToItemMap(collectionInfo, syncEntries, addressBookItems); collectionsAddressBook.push(collectionInfo); } else if (collectionInfo.type === 'CALENDAR') { - calendarItems = Object.assign(calendarItems, syncEntriesToCalendarItemMap(collectionInfo, syncEntries)); + calendarItems = syncEntriesToCalendarItemMap(collectionInfo, syncEntries, calendarItems); collectionsCalendar.push(collectionInfo); } } diff --git a/src/journal-processors.tsx b/src/journal-processors.tsx index 6ffa2a5..0da7570 100644 --- a/src/journal-processors.tsx +++ b/src/journal-processors.tsx @@ -6,8 +6,9 @@ import { EventType, ContactType } from './pim-types'; import * as EteSync from './api/EteSync'; -export function syncEntriesToItemMap(collection: EteSync.CollectionInfo, entries: List) { - let items: {[key: string]: ContactType} = {}; +export function syncEntriesToItemMap( + collection: EteSync.CollectionInfo, entries: List, base: {[key: string]: ContactType} = {}) { + let items = base; entries.forEach((syncEntry) => { let comp = new ContactType(new ICAL.Component(ICAL.parse(syncEntry.content))); @@ -49,8 +50,9 @@ function colorIntToHtml(color: number) { ((alpha > 0) ? toHex(alpha) : ''); } -export function syncEntriesToCalendarItemMap(collection: EteSync.CollectionInfo, entries: List) { - let items: {[key: string]: EventType} = {}; +export function syncEntriesToCalendarItemMap( + collection: EteSync.CollectionInfo, entries: List, base: {[key: string]: EventType} = {}) { + let items = base; const color = colorIntToHtml(collection.color);