bigbuffet-rw/app/soapbox/reducers/me.js

26 lines
569 B
JavaScript
Raw Normal View History

import {
ME_FETCH_SUCCESS,
ME_FETCH_FAIL,
ME_FETCH_SKIP,
ME_PATCH_SUCCESS,
} from '../actions/me';
2021-03-23 22:05:06 -07:00
import { AUTH_LOGGED_OUT, VERIFY_CREDENTIALS_SUCCESS } from '../actions/auth';
2020-04-02 12:28:19 -07:00
const initialState = null;
export default function me(state = initialState, action) {
switch(action.type) {
case ME_FETCH_SUCCESS:
case ME_PATCH_SUCCESS:
2020-04-17 14:10:55 -07:00
return action.me.id;
2021-03-23 22:05:06 -07:00
case VERIFY_CREDENTIALS_SUCCESS:
return state || action.account.id;
2020-04-02 12:28:19 -07:00
case ME_FETCH_FAIL:
case ME_FETCH_SKIP:
2020-04-11 12:41:13 -07:00
case AUTH_LOGGED_OUT:
return false;
default:
return state;
}
};