pleroma/app/soapbox/actions/modals.ts

29 lines
685 B
TypeScript
Raw Normal View History

import { AppDispatch } from 'soapbox/store';
2022-11-16 05:32:32 -08:00
import type { ModalType } from 'soapbox/features/ui/components/modal-root';
2020-03-27 13:59:38 -07:00
export const MODAL_OPEN = 'MODAL_OPEN';
export const MODAL_CLOSE = 'MODAL_CLOSE';
/** Open a modal of the given type */
export function openModal(type: ModalType, props?: any) {
return (dispatch: AppDispatch) => {
dispatch(closeModal(type));
dispatch(openModalSuccess(type, props));
2020-03-27 13:59:38 -07:00
};
2021-08-03 12:22:51 -07:00
}
2020-03-27 13:59:38 -07:00
const openModalSuccess = (type: ModalType, props?: any) => ({
type: MODAL_OPEN,
modalType: type,
modalProps: props,
});
/** Close the modal */
export function closeModal(type?: ModalType) {
2020-03-27 13:59:38 -07:00
return {
type: MODAL_CLOSE,
modalType: type,
2020-03-27 13:59:38 -07:00
};
2021-08-03 12:22:51 -07:00
}