List unsupported journals.

master
Tom Hacohen 7 years ago
parent e17aaaf79d
commit cb28259b24

@ -1,4 +1,5 @@
import * as React from 'react'; import * as React from 'react';
const Fragment = (React as any).Fragment;
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import { List, ListItem } from 'material-ui/List'; import { List, ListItem } from 'material-ui/List';
@ -21,28 +22,39 @@ class JournalList extends React.Component {
render() { render() {
const derived = this.props.etesync.encryptionKey; const derived = this.props.etesync.encryptionKey;
const journalMap = this.props.journals.filter((x) => ( const journalMap = this.props.journals.reduce(
// Skip shared journals for now.
!x.key
)).reduce(
(ret, journal) => { (ret, journal) => {
let cryptoManager = new EteSync.CryptoManager(derived, journal.uid, journal.version); if (journal.key) {
let info = journal.getInfo(cryptoManager); const key = 'UNSUPPORTED';
ret[info.type] = ret[info.type] || []; ret[key] = ret[key] || [];
ret[info.type].push( ret[key].push(
<Link <ListItem
key={journal.uid} key={journal.uid}
to={routeResolver.getRoute('journals._id', { journalUid: journal.uid })} >
> {journal.uid.slice(0, 20)}
<ListItem>
{info.displayName} ({journal.uid.slice(0, 5)})
</ListItem> </ListItem>
</Link> );
); } else {
let cryptoManager = new EteSync.CryptoManager(derived, journal.uid, journal.version);
let info = journal.getInfo(cryptoManager);
ret[info.type] = ret[info.type] || [];
ret[info.type].push(
<Link
key={journal.uid}
to={routeResolver.getRoute('journals._id', { journalUid: journal.uid })}
>
<ListItem>
{info.displayName} ({journal.uid.slice(0, 5)})
</ListItem>
</Link>
);
}
return ret; return ret;
}, },
{ CALENDAR: [], { CALENDAR: [],
ADDRESS_BOOK: []}); ADDRESS_BOOK: [],
UNSUPPORTED: [] as Array<JSX.Element>});
const styles = { const styles = {
paper: { paper: {
@ -63,6 +75,15 @@ class JournalList extends React.Component {
<List> <List>
{journalMap.CALENDAR} {journalMap.CALENDAR}
</List> </List>
{ journalMap.UNSUPPORTED && (
<Fragment>
<h2>Unsupported</h2>
<List>
{journalMap.UNSUPPORTED}
</List>
</Fragment>
)}
</Paper> </Paper>
); );
} }

Loading…
Cancel
Save