You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.0 KiB

8 years ago
import { ListItem } from 'material-ui/List';
import React from 'react';
export default class SignedInList extends React.Component {
8 years ago
constructor(props) {
super(props);
this.state = { tick: 0 };
this.componentDidMount = this.componentDidMount.bind(this);
this.componentWillUnmount = this.componentWillUnmount.bind(this);
this.tick = this.tick.bind(this);
}
8 years ago
8 years ago
componentDidMount() {
this.timer = setInterval(this.tick, 50);
}
8 years ago
8 years ago
componentWillUnmount() {
clearInterval(this.timer);
}
8 years ago
8 years ago
tick() {
this.setState({ tick: this.state.tick += 1 });
}
8 years ago
8 years ago
render() {
const members = this.props.members.sort((l, r) => l.at.diff(r.at))
.reverse()
8 years ago
.map(member => <ListItem key={member.id} primaryText={member.text} secondaryText={`${member.purpose}${member.at.fromNow()}`} />);
return (
<div className="mdl-cell mdl-cell--12-col">
<h3>Members signed in</h3>
{members.length ? members : 'No members currently signed in.'}
</div>
);
}
}