mirror of
https://github.com/wassname/talk.git
synced 2026-08-07 11:29:44 +08:00
replaced eslint:recommended with prettier
This commit is contained in:
@@ -1,17 +1,20 @@
|
||||
import React from 'react';
|
||||
import {connect} from 'plugin-api/beta/client/hocs';
|
||||
import {bindActionCreators} from 'redux';
|
||||
import {sortOrderSelector, sortBySelector} from 'plugin-api/beta/client/selectors/stream';
|
||||
import {setSort} from 'plugin-api/beta/client/actions/stream';
|
||||
import { connect } from 'plugin-api/beta/client/hocs';
|
||||
import { bindActionCreators } from 'redux';
|
||||
import {
|
||||
sortOrderSelector,
|
||||
sortBySelector,
|
||||
} from 'plugin-api/beta/client/selectors/stream';
|
||||
import { setSort } from 'plugin-api/beta/client/actions/stream';
|
||||
import hoistStatics from 'recompose/hoistStatics';
|
||||
import {closeMenu} from 'plugins/talk-plugin-viewing-options/client/actions';
|
||||
import { closeMenu } from 'plugins/talk-plugin-viewing-options/client/actions';
|
||||
|
||||
const mapStateToProps = (state) => ({
|
||||
const mapStateToProps = state => ({
|
||||
sortOrder: sortOrderSelector(state),
|
||||
sortBy: sortBySelector(state),
|
||||
});
|
||||
|
||||
const mapDispatchToProps = (dispatch) =>
|
||||
const mapDispatchToProps = dispatch =>
|
||||
bindActionCreators(
|
||||
{
|
||||
setSort,
|
||||
@@ -28,24 +31,26 @@ const mapDispatchToProps = (dispatch) =>
|
||||
* @param {string} sort.sortOrder
|
||||
* @return {Object} HOC
|
||||
*/
|
||||
export default ({sortBy = 'created_at', sortOrder = 'DESC', label}) => hoistStatics((WrappedComponent) => {
|
||||
class WithSortOption extends React.Component {
|
||||
setSort = () => {
|
||||
this.props.closeMenu();
|
||||
this.props.setSort({sortBy, sortOrder});
|
||||
}
|
||||
export default ({ sortBy = 'created_at', sortOrder = 'DESC', label }) =>
|
||||
hoistStatics(WrappedComponent => {
|
||||
class WithSortOption extends React.Component {
|
||||
setSort = () => {
|
||||
this.props.closeMenu();
|
||||
this.props.setSort({ sortBy, sortOrder });
|
||||
};
|
||||
|
||||
render() {
|
||||
const active = this.props.sortOrder === sortOrder && this.props.sortBy === sortBy;
|
||||
const resolvedLabel = typeof label === 'function' ? label() : label;
|
||||
return (
|
||||
<WrappedComponent
|
||||
active={active}
|
||||
setSort={this.setSort}
|
||||
label={resolvedLabel}
|
||||
/>
|
||||
);
|
||||
render() {
|
||||
const active =
|
||||
this.props.sortOrder === sortOrder && this.props.sortBy === sortBy;
|
||||
const resolvedLabel = typeof label === 'function' ? label() : label;
|
||||
return (
|
||||
<WrappedComponent
|
||||
active={active}
|
||||
setSort={this.setSort}
|
||||
label={resolvedLabel}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
return connect(mapStateToProps, mapDispatchToProps)(WithSortOption);
|
||||
});
|
||||
return connect(mapStateToProps, mapDispatchToProps)(WithSortOption);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user