remove unnecessary fetches

This commit is contained in:
Sebastian Sdorra
2018-08-30 10:10:41 +02:00
parent eb207cecfd
commit e3b6b6c18f
2 changed files with 3 additions and 9 deletions

View File

@@ -17,7 +17,6 @@ import ErrorPage from "../../components/ErrorPage";
import type { Config } from "../types/Config"; import type { Config } from "../types/Config";
import ConfigForm from "../components/form/ConfigForm"; import ConfigForm from "../components/form/ConfigForm";
import Loading from "../../components/Loading"; import Loading from "../../components/Loading";
import type { History } from "history";
type Props = { type Props = {
loading: boolean, loading: boolean,
@@ -31,23 +30,17 @@ type Props = {
configReset: void => void, configReset: void => void,
// context objects // context objects
t: string => string, t: string => string
history: History
}; };
class GlobalConfig extends React.Component<Props> { class GlobalConfig extends React.Component<Props> {
configModified = () => () => {
this.props.fetchConfig();
this.props.history.push(`/config`);
};
componentDidMount() { componentDidMount() {
this.props.configReset(); this.props.configReset();
this.props.fetchConfig(); this.props.fetchConfig();
} }
modifyConfig = (config: Config) => { modifyConfig = (config: Config) => {
this.props.modifyConfig(config, this.configModified()); this.props.modifyConfig(config);
}; };
render() { render() {

View File

@@ -132,6 +132,7 @@ function removeNullValues(config: Config) {
function reducer(state: any = {}, action: any = {}) { function reducer(state: any = {}, action: any = {}) {
switch (action.type) { switch (action.type) {
case MODIFY_CONFIG_SUCCESS:
case FETCH_CONFIG_SUCCESS: case FETCH_CONFIG_SUCCESS:
const config = removeNullValues(action.payload); const config = removeNullValues(action.payload);
return { return {