mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2025-01-10 02:07:26 +03:00
Ensured state is properly reset when starting, finisihing or failing to load visits
This commit is contained in:
parent
02a4380f7c
commit
9bdbe90716
3 changed files with 9 additions and 41 deletions
|
@ -21,9 +21,9 @@ const initialState = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export default handleActions({
|
export default handleActions({
|
||||||
[GET_SHORT_URL_DETAIL_START]: (state) => ({ ...state, loading: true }),
|
[GET_SHORT_URL_DETAIL_START]: () => ({ ...initialState, loading: true }),
|
||||||
[GET_SHORT_URL_DETAIL_ERROR]: (state) => ({ ...state, loading: false, error: true }),
|
[GET_SHORT_URL_DETAIL_ERROR]: () => ({ ...initialState, loading: false, error: true }),
|
||||||
[GET_SHORT_URL_DETAIL]: (state, { shortUrl }) => ({ shortUrl, loading: false, error: false }),
|
[GET_SHORT_URL_DETAIL]: (state, { shortUrl }) => ({ ...initialState, shortUrl }),
|
||||||
}, initialState);
|
}, initialState);
|
||||||
|
|
||||||
export const getShortUrlDetail = (buildShlinkApiClient) => (shortCode, domain) => async (dispatch, getState) => {
|
export const getShortUrlDetail = (buildShlinkApiClient) => (shortCode, domain) => async (dispatch, getState) => {
|
||||||
|
|
|
@ -33,27 +33,13 @@ const initialState = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export default handleActions({
|
export default handleActions({
|
||||||
[GET_SHORT_URL_VISITS_START]: (state) => ({
|
[GET_SHORT_URL_VISITS_START]: () => ({ ...initialState, loading: true }),
|
||||||
...state,
|
[GET_SHORT_URL_VISITS_ERROR]: () => ({ ...initialState, error: true }),
|
||||||
loading: true,
|
|
||||||
loadingLarge: false,
|
|
||||||
cancelLoad: false,
|
|
||||||
}),
|
|
||||||
[GET_SHORT_URL_VISITS_ERROR]: (state) => ({
|
|
||||||
...state,
|
|
||||||
loading: false,
|
|
||||||
loadingLarge: false,
|
|
||||||
error: true,
|
|
||||||
cancelLoad: false,
|
|
||||||
}),
|
|
||||||
[GET_SHORT_URL_VISITS]: (state, { visits, shortCode, domain }) => ({
|
[GET_SHORT_URL_VISITS]: (state, { visits, shortCode, domain }) => ({
|
||||||
|
...initialState,
|
||||||
visits,
|
visits,
|
||||||
shortCode,
|
shortCode,
|
||||||
domain,
|
domain,
|
||||||
loading: false,
|
|
||||||
loadingLarge: false,
|
|
||||||
error: false,
|
|
||||||
cancelLoad: false,
|
|
||||||
}),
|
}),
|
||||||
[GET_SHORT_URL_VISITS_LARGE]: (state) => ({ ...state, loadingLarge: true }),
|
[GET_SHORT_URL_VISITS_LARGE]: (state) => ({ ...state, loadingLarge: true }),
|
||||||
[GET_SHORT_URL_VISITS_CANCEL]: (state) => ({ ...state, cancelLoad: true }),
|
[GET_SHORT_URL_VISITS_CANCEL]: (state) => ({ ...state, cancelLoad: true }),
|
||||||
|
|
|
@ -30,27 +30,9 @@ const initialState = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export default handleActions({
|
export default handleActions({
|
||||||
[GET_TAG_VISITS_START]: (state) => ({
|
[GET_TAG_VISITS_START]: () => ({ ...initialState, loading: true }),
|
||||||
...state,
|
[GET_TAG_VISITS_ERROR]: () => ({ ...initialState, error: true }),
|
||||||
loading: true,
|
[GET_TAG_VISITS]: (state, { visits, tag }) => ({ ...initialState, visits, tag }),
|
||||||
loadingLarge: false,
|
|
||||||
cancelLoad: false,
|
|
||||||
}),
|
|
||||||
[GET_TAG_VISITS_ERROR]: (state) => ({
|
|
||||||
...state,
|
|
||||||
loading: false,
|
|
||||||
loadingLarge: false,
|
|
||||||
error: true,
|
|
||||||
cancelLoad: false,
|
|
||||||
}),
|
|
||||||
[GET_TAG_VISITS]: (state, { visits, tag }) => ({
|
|
||||||
visits,
|
|
||||||
tag,
|
|
||||||
loading: false,
|
|
||||||
loadingLarge: false,
|
|
||||||
error: false,
|
|
||||||
cancelLoad: false,
|
|
||||||
}),
|
|
||||||
[GET_TAG_VISITS_LARGE]: (state) => ({ ...state, loadingLarge: true }),
|
[GET_TAG_VISITS_LARGE]: (state) => ({ ...state, loadingLarge: true }),
|
||||||
[GET_TAG_VISITS_CANCEL]: (state) => ({ ...state, cancelLoad: true }),
|
[GET_TAG_VISITS_CANCEL]: (state) => ({ ...state, cancelLoad: true }),
|
||||||
[CREATE_VISIT]: (state, { shortUrl, visit }) => { // eslint-disable-line object-shorthand
|
[CREATE_VISIT]: (state, { shortUrl, visit }) => { // eslint-disable-line object-shorthand
|
||||||
|
|
Loading…
Reference in a new issue