diff --git a/src/app/molecules/dialog/Dialog.jsx b/src/app/molecules/dialog/Dialog.jsx index 258422d..1b918af 100644 --- a/src/app/molecules/dialog/Dialog.jsx +++ b/src/app/molecules/dialog/Dialog.jsx @@ -10,14 +10,17 @@ import ScrollView from '../../atoms/scroll/ScrollView'; import RawModal from '../../atoms/modal/RawModal'; function Dialog({ - className, isOpen, title, - contentOptions, onRequestClose, children, + className, isOpen, title, onAfterOpen, onAfterClose, + contentOptions, onRequestClose, closeFromOutside, children, }) { return (
@@ -44,7 +47,10 @@ function Dialog({ Dialog.defaultProps = { className: null, contentOptions: null, + onAfterOpen: null, + onAfterClose: null, onRequestClose: null, + closeFromOutside: true, }; Dialog.propTypes = { @@ -52,7 +58,10 @@ Dialog.propTypes = { isOpen: PropTypes.bool.isRequired, title: PropTypes.string.isRequired, contentOptions: PropTypes.node, + onAfterOpen: PropTypes.func, + onAfterClose: PropTypes.func, onRequestClose: PropTypes.func, + closeFromOutside: PropTypes.bool, children: PropTypes.node.isRequired, }; diff --git a/src/app/organisms/profile-viewer/ProfileViewer.jsx b/src/app/organisms/profile-viewer/ProfileViewer.jsx index 66fa396..bcb0cbc 100644 --- a/src/app/organisms/profile-viewer/ProfileViewer.jsx +++ b/src/app/organisms/profile-viewer/ProfileViewer.jsx @@ -253,11 +253,10 @@ function ProfileViewer() { }; }, []); - useEffect(() => { - if (isOpen) return; + const handleAfterClose = () => { setUserId(null); setRoomId(null); - }, [isOpen]); + }; function renderProfile() { const member = room.getMember(userId) || mx.getUser(userId) || {}; @@ -298,10 +297,11 @@ function ProfileViewer() { className="profile-viewer__dialog" isOpen={isOpen} title={`${username} in ${room?.name ?? ''}`} + onAfterClose={handleAfterClose} onRequestClose={() => setIsOpen(false)} contentOptions={ setIsOpen(false)} tooltip="Close" />} > - {isOpen && renderProfile()} + {roomId ? renderProfile() :
} ); } diff --git a/src/app/organisms/read-receipts/ReadReceipts.jsx b/src/app/organisms/read-receipts/ReadReceipts.jsx index 6460108..715fafe 100644 --- a/src/app/organisms/read-receipts/ReadReceipts.jsx +++ b/src/app/organisms/read-receipts/ReadReceipts.jsx @@ -30,12 +30,10 @@ function ReadReceipts() { }; }, []); - useEffect(() => { - if (isOpen === false) { - setReaders([]); - setRoomId(null); - } - }, [isOpen]); + const handleAfterClose = () => { + setReaders([]); + setRoomId(null); + }; function renderPeople(userId) { const room = initMatrix.matrixClient.getRoom(roomId); @@ -62,6 +60,7 @@ function ReadReceipts() { setIsOpen(false)} contentOptions={ setIsOpen(false)} tooltip="Close" />} >