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

Loading…
Cancel
Save