JournalsList: change to a functional component

master
Tal Leibman 5 years ago committed by Tom Hacohen
parent 2c02ec839e
commit a8bdc076d9

@ -15,30 +15,29 @@ import { routeResolver } from '../App';
import { JournalsData, UserInfoData, CredentialsData } from '../store';
class JournalsList extends React.PureComponent {
public props: {
interface PropsType {
etesync: CredentialsData;
journals: JournalsData;
userInfo: UserInfoData;
history: History;
};
}
export default function JournalsList(props: PropsType) {
const derived = props.etesync.encryptionKey;
constructor(props: any) {
super(props);
this.journalClicked = this.journalClicked.bind(this);
function journalClicked(journalUid: string) {
props.history.push(routeResolver.getRoute('journals._id', { journalUid }));
}
public render() {
const derived = this.props.etesync.encryptionKey;
const journalMap = this.props.journals.reduce(
const journalMap = props.journals.reduce(
(ret, journal) => {
const userInfo = this.props.userInfo;
const userInfo = props.userInfo;
const keyPair = userInfo.getKeyPair(userInfo.getCryptoManager(derived));
const cryptoManager = journal.getCryptoManager(derived, keyPair);
const info = journal.getInfo(cryptoManager);
ret[info.type] = ret[info.type] || [];
ret[info.type].push(
<ListItem key={journal.uid} onClick={() => this.journalClicked(journal.uid)}>
<ListItem key={journal.uid} onClick={() => journalClicked(journal.uid)}>
{info.displayName} ({journal.uid.slice(0, 5)})
</ListItem>
);
@ -80,10 +79,3 @@ class JournalsList extends React.PureComponent {
</Container>
);
}
private journalClicked(journalUid: string) {
this.props.history.push(routeResolver.getRoute('journals._id', { journalUid }));
}
}
export default JournalsList;

Loading…
Cancel
Save