diff --git a/src/renderer/components/modal/modal.component.tsx b/src/renderer/components/modal/modal.component.tsx index ddffd326..52a38ed3 100644 --- a/src/renderer/components/modal/modal.component.tsx +++ b/src/renderer/components/modal/modal.component.tsx @@ -8,46 +8,32 @@ import { GuardModal } from "./modal-types/guard-modal.component"; import { UninstallModal } from "./modal-types/uninstall-modal.component"; import { InstallationFolderModal } from "./modal-types/installation-folder-modal.component"; import { EditVersionModal } from "./modal-types/edit-version-modal.component"; +import { useObservable } from "renderer/hooks/use-observable.hook"; export function Modal() { - const [modalType, setModalType] = useState(null as ModalType); - const [modalYOut, setModalYOut] = useState(window.innerHeight); + const modalSevice = ModalService.getInsance(); - const modalSevice = ModalService.getInsance(); - - const handleResize = () => setModalYOut(window.innerHeight); - - useEffect(() => { - modalSevice.modalType$.subscribe(type => { - setModalType(type); - }); - - window.addEventListener("resize", handleResize); - - return () => { - window.removeEventListener("resize", handleResize); - } - }, []) + const modalType = useObservable(modalSevice.modalType$); return ( - - {modalType && ( -
- modalSevice.resolve({exitCode: ModalExitCode.NO_CHOICE})} className="absolute top-0 bottom-0 right-0 left-0 bg-black" initial={{opacity: 0}} animate={{opacity: modalType && .60}} exit={{opacity: 0}} transition={{duration: .2}}/> - -
- - {modalType === ModalType.STEAM_LOGIN && } - {modalType === ModalType.GUARD_CODE && } - {modalType === ModalType.UNINSTALL && } - {modalType === ModalType.INSTALLATION_FOLDER && } - {modalType === ModalType.EDIT_VERSION && } - {modalType === ModalType.CLONE_VERSION && } -
-
-
- )} -
+ + {modalType && ( +
+ modalSevice.resolve({exitCode: ModalExitCode.NO_CHOICE})} className="absolute top-0 bottom-0 right-0 left-0 bg-black" initial={{opacity: 0}} animate={{opacity: modalType && .60}} exit={{opacity: 0}} transition={{duration: .2}}/> + +
+ + {modalType === ModalType.STEAM_LOGIN && } + {modalType === ModalType.GUARD_CODE && } + {modalType === ModalType.UNINSTALL && } + {modalType === ModalType.INSTALLATION_FOLDER && } + {modalType === ModalType.EDIT_VERSION && } + {modalType === ModalType.CLONE_VERSION && } +
+
+
+ )} +
) }