export function followAccount(id, reblogs = true) {
return (dispatch, getState) => {
const alreadyFollowing = getState().getIn(['relationships', id, 'following']);
- dispatch(followAccountRequest(id));
+ const locked = getState().getIn(['accounts', id, 'locked'], false);
+
+ dispatch(followAccountRequest(id, locked));
api(getState).post(`/api/v1/accounts/${id}/follow`, { reblogs }).then(response => {
dispatch(followAccountSuccess(response.data, alreadyFollowing));
}).catch(error => {
- dispatch(followAccountFail(error));
+ dispatch(followAccountFail(error, locked));
});
};
};
};
};
-export function followAccountRequest(id) {
+export function followAccountRequest(id, locked) {
return {
type: ACCOUNT_FOLLOW_REQUEST,
id,
+ locked,
+ skipLoading: true,
};
};
type: ACCOUNT_FOLLOW_SUCCESS,
relationship,
alreadyFollowing,
+ skipLoading: true,
};
};
-export function followAccountFail(error) {
+export function followAccountFail(error, locked) {
return {
type: ACCOUNT_FOLLOW_FAIL,
error,
+ locked,
+ skipLoading: true,
};
};
return {
type: ACCOUNT_UNFOLLOW_REQUEST,
id,
+ skipLoading: true,
};
};
type: ACCOUNT_UNFOLLOW_SUCCESS,
relationship,
statuses,
+ skipLoading: true,
};
};
return {
type: ACCOUNT_UNFOLLOW_FAIL,
error,
+ skipLoading: true,
};
};
import {
ACCOUNT_FOLLOW_SUCCESS,
+ ACCOUNT_FOLLOW_REQUEST,
+ ACCOUNT_FOLLOW_FAIL,
ACCOUNT_UNFOLLOW_SUCCESS,
+ ACCOUNT_UNFOLLOW_REQUEST,
+ ACCOUNT_UNFOLLOW_FAIL,
ACCOUNT_BLOCK_SUCCESS,
ACCOUNT_UNBLOCK_SUCCESS,
ACCOUNT_MUTE_SUCCESS,
export default function relationships(state = initialState, action) {
switch(action.type) {
+ case ACCOUNT_FOLLOW_REQUEST:
+ return state.setIn([action.id, action.locked ? 'requested' : 'following'], true);
+ case ACCOUNT_FOLLOW_FAIL:
+ return state.setIn([action.id, action.locked ? 'requested' : 'following'], false);
+ case ACCOUNT_UNFOLLOW_REQUEST:
+ return state.setIn([action.id, 'following'], false);
+ case ACCOUNT_UNFOLLOW_FAIL:
+ return state.setIn([action.id, 'following'], true);
case ACCOUNT_FOLLOW_SUCCESS:
case ACCOUNT_UNFOLLOW_SUCCESS:
case ACCOUNT_BLOCK_SUCCESS: