Optimise PIM page a bit more.

master
Tom Hacohen 7 years ago
parent 95c8bff9be
commit 7b7c96719d

@ -51,10 +51,10 @@ const itemsSelector = createSelector(
const collectionInfo = syncJournal.collection; const collectionInfo = syncJournal.collection;
if (collectionInfo.type === 'ADDRESS_BOOK') { if (collectionInfo.type === 'ADDRESS_BOOK') {
addressBookItems = Object.assign(addressBookItems, syncEntriesToItemMap(collectionInfo, syncEntries)); addressBookItems = syncEntriesToItemMap(collectionInfo, syncEntries, addressBookItems);
collectionsAddressBook.push(collectionInfo); collectionsAddressBook.push(collectionInfo);
} else if (collectionInfo.type === 'CALENDAR') { } else if (collectionInfo.type === 'CALENDAR') {
calendarItems = Object.assign(calendarItems, syncEntriesToCalendarItemMap(collectionInfo, syncEntries)); calendarItems = syncEntriesToCalendarItemMap(collectionInfo, syncEntries, calendarItems);
collectionsCalendar.push(collectionInfo); collectionsCalendar.push(collectionInfo);
} }
} }

@ -6,8 +6,9 @@ import { EventType, ContactType } from './pim-types';
import * as EteSync from './api/EteSync'; import * as EteSync from './api/EteSync';
export function syncEntriesToItemMap(collection: EteSync.CollectionInfo, entries: List<EteSync.SyncEntry>) { export function syncEntriesToItemMap(
let items: {[key: string]: ContactType} = {}; collection: EteSync.CollectionInfo, entries: List<EteSync.SyncEntry>, base: {[key: string]: ContactType} = {}) {
let items = base;
entries.forEach((syncEntry) => { entries.forEach((syncEntry) => {
let comp = new ContactType(new ICAL.Component(ICAL.parse(syncEntry.content))); let comp = new ContactType(new ICAL.Component(ICAL.parse(syncEntry.content)));
@ -49,8 +50,9 @@ function colorIntToHtml(color: number) {
((alpha > 0) ? toHex(alpha) : ''); ((alpha > 0) ? toHex(alpha) : '');
} }
export function syncEntriesToCalendarItemMap(collection: EteSync.CollectionInfo, entries: List<EteSync.SyncEntry>) { export function syncEntriesToCalendarItemMap(
let items: {[key: string]: EventType} = {}; collection: EteSync.CollectionInfo, entries: List<EteSync.SyncEntry>, base: {[key: string]: EventType} = {}) {
let items = base;
const color = colorIntToHtml(collection.color); const color = colorIntToHtml(collection.color);

Loading…
Cancel
Save