Organise calendars and address books in lists.

master
Tom Hacohen 7 years ago
parent 3faa7b3ed6
commit b668e6478a

@ -1,6 +1,8 @@
import * as React from 'react'; import * as React from 'react';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import { List, ListItem } from 'material-ui/List';
import { EteSyncContextType } from './EteSyncContext'; import { EteSyncContextType } from './EteSyncContext';
import * as EteSync from './api/EteSync'; import * as EteSync from './api/EteSync';
@ -38,26 +40,38 @@ export class JournalList extends React.Component {
render() { render() {
const derived = this.props.etesync.encryptionKey; const derived = this.props.etesync.encryptionKey;
const journals = this.state.journals.map((journal, idx) => { const journalMap = this.state.journals.reduce(
(ret, journal) => {
let cryptoManager = new EteSync.CryptoManager(derived, journal.uid, journal.version); let cryptoManager = new EteSync.CryptoManager(derived, journal.uid, journal.version);
let info = journal.getInfo(cryptoManager); let info = journal.getInfo(cryptoManager);
return ( ret[info.type] = ret[info.type] || [];
<li key={journal.uid}> ret[info.type].push(
<Link <Link
key={journal.uid}
to={routeResolver.getRoute('journals._id', { journalUid: journal.uid })} to={routeResolver.getRoute('journals._id', { journalUid: journal.uid })}
className="Drawer-navlink" className="Drawer-navlink"
> >
{info.displayName}: {info.type} ({journal.uid}) <ListItem>
{info.displayName} ({journal.uid.slice(0, 5)})
</ListItem>
</Link> </Link>
</li>
); );
}); return ret;
},
{ CALENDAR: [],
ADDRESS_BOOK: []});
return ( return (
<div> <div>
<ul> <h2>Address Books</h2>
{journals} <List>
</ul> {journalMap.ADDRESS_BOOK}
</List>
<h2>Calendars</h2>
<List>
{journalMap.CALENDAR}
</List>
</div> </div>
); );
} }

Loading…
Cancel
Save