2022-11-22 00:30:53 +09:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import React from 'react';
|
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
|
|
|
import { injectIntl } from 'react-intl';
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { createSelector } from 'reselect';
|
|
|
|
|
|
|
|
const getOrderedLists = createSelector([state => state.get('lists')], lists => {
|
|
|
|
if (!lists) {
|
|
|
|
return lists;
|
|
|
|
}
|
|
|
|
|
|
|
|
return lists.toList().filter(item => !!item).sort((a, b) => a.get('title').localeCompare(b.get('title')));
|
|
|
|
});
|
|
|
|
|
|
|
|
const mapStateToProps = state => ({
|
|
|
|
lists: getOrderedLists(state),
|
|
|
|
});
|
|
|
|
|
|
|
|
export default @connect(mapStateToProps)
|
|
|
|
@injectIntl
|
|
|
|
class Lists extends ImmutablePureComponent {
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
params: PropTypes.object.isRequired,
|
|
|
|
dispatch: PropTypes.func.isRequired,
|
|
|
|
lists: ImmutablePropTypes.list,
|
|
|
|
intl: PropTypes.object.isRequired,
|
|
|
|
multiColumn: PropTypes.bool,
|
|
|
|
};
|
|
|
|
|
2022-11-30 03:10:06 +09:00
|
|
|
state = {
|
|
|
|
logs: [],
|
|
|
|
};
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
this.eventSource = new EventSource('/api/v1/activity_log');
|
|
|
|
this.eventSource.onmessage = (event) => {
|
|
|
|
this.setState({ logs: [...this.state.logs, JSON.parse(event.data)] });
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
componentWillUnmount() {
|
|
|
|
if (this.eventSource) {
|
|
|
|
this.eventSource.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-22 00:30:53 +09:00
|
|
|
render () {
|
2022-11-30 03:10:06 +09:00
|
|
|
return <div>{this.state.logs.map(x => (<div>{JSON.stringify(x)}</div>))}</div>;
|
2022-11-22 00:30:53 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|