mattermost-mobile/src/reducers/posts.js
Thomas Hopkins 23a8676c19 Fix: Clear stores when user logs out (#65)
* Import missing action types for logout

* Correctly destructure logout response from doFetchWithResponse

* Return to SelectServer upon logout

* Add todo regarding clearing clientConfig upon logout
2016-10-21 10:17:36 -07:00

34 lines
785 B
JavaScript

import {PostsTypes, LogoutTypes} from 'constants';
const types = {...PostsTypes, ...LogoutTypes};
export const initState = {
status: 'not fetched',
error: null,
data: {}
};
export default function reducePosts(state = initState, action) {
switch (action.type) {
case types.FETCH_POSTS_REQUEST:
return {...state,
status: 'fetching',
error: null
};
case types.FETCH_POSTS_SUCCESS:
return {...state,
status: 'fetched',
data: action.data.posts
};
case types.FETCH_POSTS_FAILURE:
return {...state,
status: 'failed',
error: action.error
};
case types.LOGOUT_SUCCESS:
return initState;
default:
return state;
}
}