only fetch index Resources once (and not twice)

This commit is contained in:
Maren Süwer
2018-10-15 13:46:42 +02:00
parent f4ed4792bd
commit efdc57055d
5 changed files with 52 additions and 21 deletions

View File

@@ -5,7 +5,12 @@ import * as types from "./types";
import { apiClient, UNAUTHORIZED_ERROR } from "@scm-manager/ui-components";
import { isPending } from "./pending";
import { getFailure } from "./failure";
import { callFetchIndexResources, fetchIndexResources } from "./indexResource";
import {
callFetchIndexResources,
FETCH_INDEXRESOURCES_SUCCESS,
fetchIndexResources,
fetchIndexResourcesSuccess
} from "./indexResource";
// Action
@@ -154,15 +159,13 @@ export const login = (
return callFetchIndexResources();
})
.then(response => {
dispatch(fetchIndexResourcesSuccess(response));
const meLink = response._links.me.href;
return callFetchMe(meLink);
})
.then(me => {
dispatch(loginSuccess(me));
})
.then(() => {
dispatch(fetchIndexResources());
})
.catch(err => {
dispatch(loginFailure(err));
});