Mangane/app/soapbox/reducers/dropdown_menu.js

20 lines
609 B
JavaScript
Raw Normal View History

2021-09-12 18:25:44 +02:00
import { Map as ImmutableMap } from 'immutable';
2020-03-27 21:59:38 +01:00
import {
DROPDOWN_MENU_OPEN,
DROPDOWN_MENU_CLOSE,
} from '../actions/dropdown_menu';
2021-09-12 18:25:44 +02:00
const initialState = ImmutableMap({ openId: null, placement: null, keyboard: false });
2020-03-27 21:59:38 +01:00
export default function dropdownMenu(state = initialState, action) {
switch (action.type) {
2022-05-11 23:06:35 +02:00
case DROPDOWN_MENU_OPEN:
return state.merge({ openId: action.id, placement: action.placement, keyboard: action.keyboard });
case DROPDOWN_MENU_CLOSE:
return state.get('openId') === action.id ? state.set('openId', null) : state;
default:
return state;
2020-03-27 21:59:38 +01:00
}
}