mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-11 23:57:11 -07:00
Initial Commit Rework
This commit is contained in:
parent
74a4cc048c
commit
95051cbd63
2483 changed files with 101351 additions and 111396 deletions
82
frontend/src/Components/Form/OAuthInputConnector.js
Normal file
82
frontend/src/Components/Form/OAuthInputConnector.js
Normal file
|
@ -0,0 +1,82 @@
|
|||
import PropTypes from 'prop-types';
|
||||
import React, { Component } from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { createSelector } from 'reselect';
|
||||
import { startOAuth, resetOAuth } from 'Store/Actions/oAuthActions';
|
||||
import OAuthInput from './OAuthInput';
|
||||
|
||||
function createMapStateToProps() {
|
||||
return createSelector(
|
||||
(state) => state.oAuth,
|
||||
(oAuth) => {
|
||||
return oAuth;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
const mapDispatchToProps = {
|
||||
startOAuth,
|
||||
resetOAuth
|
||||
};
|
||||
|
||||
class OAuthInputConnector extends Component {
|
||||
|
||||
//
|
||||
// Lifecycle
|
||||
|
||||
componentDidUpdate(prevProps) {
|
||||
const {
|
||||
accessToken,
|
||||
accessTokenSecret,
|
||||
onChange
|
||||
} = this.props;
|
||||
|
||||
if (accessToken &&
|
||||
accessToken !== prevProps.accessToken &&
|
||||
accessTokenSecret &&
|
||||
accessTokenSecret !== prevProps.accessTokenSecret) {
|
||||
onChange({ name: 'AccessToken', value: accessToken });
|
||||
onChange({ name: 'AccessTokenSecret', value: accessTokenSecret });
|
||||
}
|
||||
}
|
||||
|
||||
componentWillUnmount = () => {
|
||||
this.props.resetOAuth();
|
||||
}
|
||||
|
||||
//
|
||||
// Listeners
|
||||
|
||||
onPress = () => {
|
||||
const {
|
||||
provider,
|
||||
providerData
|
||||
} = this.props;
|
||||
|
||||
this.props.startOAuth({ provider, providerData });
|
||||
}
|
||||
|
||||
//
|
||||
// Render
|
||||
|
||||
render() {
|
||||
return (
|
||||
<OAuthInput
|
||||
{...this.props}
|
||||
onPress={this.onPress}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
OAuthInputConnector.propTypes = {
|
||||
accessToken: PropTypes.string,
|
||||
accessTokenSecret: PropTypes.string,
|
||||
provider: PropTypes.string.isRequired,
|
||||
providerData: PropTypes.object.isRequired,
|
||||
onChange: PropTypes.func.isRequired,
|
||||
startOAuth: PropTypes.func.isRequired,
|
||||
resetOAuth: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
export default connect(createMapStateToProps, mapDispatchToProps)(OAuthInputConnector);
|
Loading…
Add table
Add a link
Reference in a new issue