TypeScript: reducers/me
This commit is contained in:
parent
41ae50c495
commit
c51441c026
1 changed files with 8 additions and 4 deletions
|
@ -10,17 +10,21 @@ import {
|
|||
ME_PATCH_SUCCESS,
|
||||
} from '../actions/me';
|
||||
|
||||
const initialState = null;
|
||||
import type { AxiosError } from 'axios';
|
||||
import type { AnyAction } from 'redux';
|
||||
import type { Me } from 'soapbox/types/soapbox';
|
||||
|
||||
const handleForbidden = (state, error) => {
|
||||
if ([401, 403].includes(error.response?.status)) {
|
||||
const initialState: Me = null;
|
||||
|
||||
const handleForbidden = (state: Me, error: AxiosError) => {
|
||||
if (([401, 403] as any[]).includes(error.response?.status)) {
|
||||
return false;
|
||||
} else {
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
export default function me(state = initialState, action) {
|
||||
export default function me(state: Me = initialState, action: AnyAction): Me {
|
||||
switch(action.type) {
|
||||
case ME_FETCH_SUCCESS:
|
||||
case ME_PATCH_SUCCESS:
|
Loading…
Reference in a new issue