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

29 lines
703 B
JavaScript
Raw Normal View History

2022-01-10 14:01:24 -08:00
import { Map as ImmutableMap } from 'immutable';
2020-09-10 18:18:04 -07:00
import {
PROFILE_HOVER_CARD_OPEN,
PROFILE_HOVER_CARD_CLOSE,
PROFILE_HOVER_CARD_UPDATE,
2020-09-10 18:18:04 -07:00
} from 'soapbox/actions/profile_hover_card';
const initialState = ImmutableMap();
export default function profileHoverCard(state = initialState, action) {
switch(action.type) {
case PROFILE_HOVER_CARD_OPEN:
return ImmutableMap({
ref: action.ref,
accountId: action.accountId,
});
case PROFILE_HOVER_CARD_UPDATE:
return state.set('hovered', true);
case PROFILE_HOVER_CARD_CLOSE:
if (state.get('hovered') === true && !action.force)
return state;
else
return ImmutableMap();
default:
return state;
}
}