Improve how account detailed view looks, load account's statuses

This commit is contained in:
Eugen Rochko
2016-09-18 18:18:46 +02:00
parent dafcb02153
commit 0967961de7
9 changed files with 208 additions and 76 deletions

View File

@ -14,6 +14,10 @@ export const ACCOUNT_UNFOLLOW_REQUEST = 'ACCOUNT_UNFOLLOW_REQUEST';
export const ACCOUNT_UNFOLLOW_SUCCESS = 'ACCOUNT_UNFOLLOW_SUCCESS';
export const ACCOUNT_UNFOLLOW_FAIL = 'ACCOUNT_UNFOLLOW_FAIL';
export const ACCOUNT_TIMELINE_FETCH_REQUEST = 'ACCOUNT_TIMELINE_FETCH_REQUEST';
export const ACCOUNT_TIMELINE_FETCH_SUCCESS = 'ACCOUNT_TIMELINE_FETCH_SUCCESS';
export const ACCOUNT_TIMELINE_FETCH_FAIL = 'ACCOUNT_TIMELINE_FETCH_FAIL';
export function setAccountSelf(account) {
return {
type: ACCOUNT_SET_SELF,
@ -33,6 +37,18 @@ export function fetchAccount(id) {
};
};
export function fetchAccountTimeline(id) {
return (dispatch, getState) => {
dispatch(fetchAccountTimelineRequest(id));
api(getState).get(`/api/accounts/${id}/statuses`).then(response => {
dispatch(fetchAccountTimelineSuccess(id, response.data));
}).catch(error => {
dispatch(fetchAccountTimelineFail(id, error));
});
};
};
export function fetchAccountRequest(id) {
return {
type: ACCOUNT_FETCH_REQUEST,
@ -120,3 +136,26 @@ export function unfollowAccountFail(error) {
error: error
};
};
export function fetchAccountTimelineRequest(id) {
return {
type: ACCOUNT_TIMELINE_FETCH_REQUEST,
id: id
};
};
export function fetchAccountTimelineSuccess(id, statuses) {
return {
type: ACCOUNT_TIMELINE_FETCH_SUCCESS,
id: id,
statuses: statuses
};
};
export function fetchAccountTimelineFail(id, error) {
return {
type: ACCOUNT_TIMELINE_FETCH_FAIL,
id: id,
error: error
};
};