Pim: cleanup the syncenttry and journals processing..

master
Tom Hacohen 7 years ago
parent cabd82b382
commit ce71c5422f

@ -89,21 +89,20 @@ class Pim extends React.Component {
let collectionsAddressBook: Array<EteSync.CollectionInfo> = [];
let collectionsCalendar: Array<EteSync.CollectionInfo> = [];
let syncEntriesCalendar = [];
let syncEntriesAddressBook = [];
for (const journal of this.props.journals) {
const journalMap = this.props.journals.reduce(
(ret, journal) => {
const journalEntries = this.props.entries[journal.uid];
const cryptoManager = new EteSync.CryptoManager(derived, journal.uid, journal.version);
let prevUid: string | null = null;
if (!journalEntries || !journalEntries.value) {
continue;
return ret;
}
// FIXME: Skip shared journals for now
if (journal.key) {
continue;
return ret;
}
const collectionInfo = journal.getInfo(cryptoManager);
@ -116,17 +115,21 @@ class Pim extends React.Component {
});
if (collectionInfo.type === 'ADDRESS_BOOK') {
syncEntriesAddressBook.push(syncEntriesToItemMap(collectionInfo, syncEntries));
ret.ADDRESS_BOOK.push(syncEntriesToItemMap(collectionInfo, syncEntries));
collectionsAddressBook.push(collectionInfo);
} else if (collectionInfo.type === 'CALENDAR') {
syncEntriesCalendar.push(syncEntriesToCalendarItemMap(collectionInfo, syncEntries));
ret.CALENDAR.push(syncEntriesToCalendarItemMap(collectionInfo, syncEntries));
collectionsCalendar.push(collectionInfo);
}
}
return ret;
},
{ CALENDAR: [] as Array<{[key: string]: EventType}>,
ADDRESS_BOOK: [] as Array<{[key: string]: ContactType}>,
UNSUPPORTED: [] as Array<any>});
let addressBookItems = syncEntriesAddressBook.reduce((base, x) => Object.assign(base, x), {});
let calendarItems = syncEntriesCalendar.reduce((base, x) => Object.assign(base, x), {});
let addressBookItems = journalMap.ADDRESS_BOOK.reduce((base, x) => Object.assign(base, x), {});
let calendarItems = journalMap.CALENDAR.reduce((base, x) => Object.assign(base, x), {});
return (
<Switch>

Loading…
Cancel
Save