TypeScript: reducers/me

next-interactions
Alex Gleason 2022-04-04 12:44:05 -05:00
rodzic 41ae50c495
commit c51441c026
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
1 zmienionych plików z 8 dodań i 4 usunięć

Wyświetl plik

@ -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: