Pim: cleanup the syncenttry and journals processing..

master
Tom Hacohen 7 years ago
parent cabd82b382
commit ce71c5422f

@ -89,44 +89,47 @@ 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) { return ret;
continue; }
}
// FIXME: Skip shared journals for now
// FIXME: Skip shared journals for now if (journal.key) {
if (journal.key) { return ret;
continue; }
}
const collectionInfo = journal.getInfo(cryptoManager);
const collectionInfo = journal.getInfo(cryptoManager);
const syncEntries = journalEntries.value.map((entry: EteSync.Entry) => {
const syncEntries = journalEntries.value.map((entry: EteSync.Entry) => { let syncEntry = entry.getSyncEntry(cryptoManager, prevUid);
let syncEntry = entry.getSyncEntry(cryptoManager, prevUid); prevUid = entry.uid;
prevUid = entry.uid;
return syncEntry;
return syncEntry; });
});
if (collectionInfo.type === 'ADDRESS_BOOK') {
if (collectionInfo.type === 'ADDRESS_BOOK') { ret.ADDRESS_BOOK.push(syncEntriesToItemMap(collectionInfo, syncEntries));
syncEntriesAddressBook.push(syncEntriesToItemMap(collectionInfo, syncEntries)); collectionsAddressBook.push(collectionInfo);
collectionsAddressBook.push(collectionInfo); } else if (collectionInfo.type === 'CALENDAR') {
} else if (collectionInfo.type === 'CALENDAR') { ret.CALENDAR.push(syncEntriesToCalendarItemMap(collectionInfo, syncEntries));
syncEntriesCalendar.push(syncEntriesToCalendarItemMap(collectionInfo, syncEntries)); collectionsCalendar.push(collectionInfo);
collectionsCalendar.push(collectionInfo); }
}
return ret;
} },
{ CALENDAR: [] as Array<{[key: string]: EventType}>,
let addressBookItems = syncEntriesAddressBook.reduce((base, x) => Object.assign(base, x), {}); ADDRESS_BOOK: [] as Array<{[key: string]: ContactType}>,
let calendarItems = syncEntriesCalendar.reduce((base, x) => Object.assign(base, x), {}); UNSUPPORTED: [] as Array<any>});
let addressBookItems = journalMap.ADDRESS_BOOK.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