gab-social/app/javascript/gabsocial/actions/popover.js

29 lines
637 B
JavaScript
Raw Normal View History

2020-02-28 15:20:47 +00:00
export const POPOVER_OPEN = 'POPOVER_OPEN'
export const POPOVER_CLOSE = 'POPOVER_CLOSE'
2020-03-11 23:56:18 +00:00
export function openPopover(type, props) {
2020-05-01 06:50:27 +01:00
return function (dispatch, getState) {
const currentlyOpenPopover = getState().getIn(['popover', 'popoverType'])
if (currentlyOpenPopover === type) {
dispatch(closePopover(type))
} else {
dispatch(handleOpenPopover(type, props))
}
2020-02-28 15:20:47 +00:00
}
}
export function closePopover(type) {
return {
type: POPOVER_CLOSE,
popoverType: type,
}
}
2020-05-01 06:50:27 +01:00
const handleOpenPopover = (type, props) => {
return {
type: POPOVER_OPEN,
popoverType: type,
popoverProps: props,
}
}