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

22 lines
592 B
JavaScript
Raw Normal View History

import {
FETCH_TOKENS_SUCCESS,
REVOKE_TOKEN_SUCCESS,
} from '../actions/auth';
import { Map as ImmutableMap, List as ImmutableList, fromJS } from 'immutable';
const initialState = ImmutableMap({
tokens: ImmutableList(),
});
export default function security(state = initialState, action) {
switch(action.type) {
case FETCH_TOKENS_SUCCESS:
return state.set('tokens', fromJS(action.tokens));
case REVOKE_TOKEN_SUCCESS:
const idx = state.get('tokens').findIndex(t => t.get('id') === action.id);
return state.deleteIn(['tokens', idx]);
default:
return state;
}
2021-08-03 12:22:51 -07:00
}