mirror of
https://github.com/wassname/talk.git
synced 2026-06-29 16:16:48 +08:00
49 lines
1.3 KiB
JavaScript
49 lines
1.3 KiB
JavaScript
import { compose, gql } from 'react-apollo';
|
|
import { bindActionCreators } from 'redux';
|
|
import { connect, withFragments, excludeIf } from 'plugin-api/beta/client/hocs';
|
|
import AddEmailAddressDialog from '../components/AddEmailAddressDialog';
|
|
import { notify } from 'coral-framework/actions/notification';
|
|
import { withAttachLocalAuth } from '../hocs';
|
|
import { startAttach, finishAttach } from '../actions';
|
|
import get from 'lodash/get';
|
|
|
|
const mapStateToProps = ({ talkPluginLocalAuth: state }) => ({
|
|
inProgress: state.inProgress,
|
|
});
|
|
|
|
const mapDispatchToProps = dispatch =>
|
|
bindActionCreators({ notify, startAttach, finishAttach }, dispatch);
|
|
|
|
const withData = withFragments({
|
|
root: gql`
|
|
fragment TalkPluginLocalAuth_AddEmailAddressDialog_root on RootQuery {
|
|
me {
|
|
id
|
|
email
|
|
state {
|
|
status {
|
|
username {
|
|
status
|
|
}
|
|
}
|
|
}
|
|
}
|
|
settings {
|
|
requireEmailConfirmation
|
|
}
|
|
}
|
|
`,
|
|
});
|
|
|
|
export default compose(
|
|
connect(mapStateToProps, mapDispatchToProps),
|
|
withAttachLocalAuth,
|
|
withData,
|
|
excludeIf(
|
|
({ root: { me }, inProgress }) =>
|
|
!me ||
|
|
get(me, 'state.status.username.status') === 'UNSET' ||
|
|
(me.email && !inProgress)
|
|
)
|
|
)(AddEmailAddressDialog);
|