2023-05-30 06:04:50 -07:00
|
|
|
import { AppDispatch } from 'soapbox/store';
|
|
|
|
|
2022-11-16 05:32:32 -08:00
|
|
|
import type { ModalType } from 'soapbox/features/ui/components/modal-root';
|
2022-11-12 06:18:24 -08:00
|
|
|
|
2024-08-11 01:48:58 -07:00
|
|
|
const MODAL_OPEN = 'MODAL_OPEN';
|
2024-05-12 16:18:04 -07:00
|
|
|
const MODAL_CLOSE = 'MODAL_CLOSE';
|
2020-03-27 13:59:38 -07:00
|
|
|
|
2022-04-10 18:31:24 -07:00
|
|
|
/** Open a modal of the given type */
|
2024-05-12 16:18:04 -07:00
|
|
|
const openModal = (type: ModalType, props?: any) =>
|
|
|
|
(dispatch: AppDispatch) => {
|
2023-05-30 06:04:50 -07:00
|
|
|
dispatch(closeModal(type));
|
|
|
|
dispatch(openModalSuccess(type, props));
|
2020-03-27 13:59:38 -07:00
|
|
|
};
|
|
|
|
|
2023-05-30 06:04:50 -07:00
|
|
|
const openModalSuccess = (type: ModalType, props?: any) => ({
|
|
|
|
type: MODAL_OPEN,
|
|
|
|
modalType: type,
|
|
|
|
modalProps: props,
|
|
|
|
});
|
|
|
|
|
2022-04-10 18:31:24 -07:00
|
|
|
/** Close the modal */
|
2024-05-12 16:18:04 -07:00
|
|
|
const closeModal = (type?: ModalType) => ({
|
|
|
|
type: MODAL_CLOSE,
|
|
|
|
modalType: type,
|
|
|
|
});
|
|
|
|
|
2024-08-16 15:26:29 -07:00
|
|
|
type ModalsAction =
|
|
|
|
ReturnType<typeof openModalSuccess>
|
|
|
|
| ReturnType<typeof closeModal>;
|
|
|
|
|
2024-05-12 16:18:04 -07:00
|
|
|
export {
|
|
|
|
MODAL_OPEN,
|
|
|
|
MODAL_CLOSE,
|
|
|
|
openModal,
|
|
|
|
closeModal,
|
2024-08-16 15:26:29 -07:00
|
|
|
type ModalsAction,
|
2024-05-12 16:18:04 -07:00
|
|
|
};
|