From 02c4b8b97b00fe4e31bddb0eeb112baa835a606d Mon Sep 17 00:00:00 2001 From: "adeel.tajamul" Date: Tue, 21 Feb 2023 12:20:19 +0500 Subject: [PATCH] fix: post loading slow --- src/components/HTMLLoader.jsx | 6 ++++-- src/components/PostPreviewPane.jsx | 8 +++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/components/HTMLLoader.jsx b/src/components/HTMLLoader.jsx index 5294f942..cac3a7f2 100644 --- a/src/components/HTMLLoader.jsx +++ b/src/components/HTMLLoader.jsx @@ -13,12 +13,12 @@ const defaultSanitizeOptions = { }; function HTMLLoader({ - htmlNode, componentId, cssClassName, testId, + htmlNode, componentId, cssClassName, testId, delay, }) { const sanitizedMath = DOMPurify.sanitize(htmlNode, { ...defaultSanitizeOptions }); const previewRef = useRef(); - const debouncedPostContent = useDebounce(htmlNode, 500); + const debouncedPostContent = useDebounce(htmlNode, delay); useEffect(() => { let promise = Promise.resolve(); // Used to hold chain of typesetting calls @@ -45,6 +45,7 @@ HTMLLoader.propTypes = { componentId: PropTypes.string, cssClassName: PropTypes.string, testId: PropTypes.string, + delay: PropTypes.number, }; HTMLLoader.defaultProps = { @@ -52,6 +53,7 @@ HTMLLoader.defaultProps = { componentId: null, cssClassName: '', testId: '', + delay: 0, }; export default HTMLLoader; diff --git a/src/components/PostPreviewPane.jsx b/src/components/PostPreviewPane.jsx index dba69d84..44d39233 100644 --- a/src/components/PostPreviewPane.jsx +++ b/src/components/PostPreviewPane.jsx @@ -29,7 +29,13 @@ function PostPreviewPane({ className="float-right p-3" iconClassNames="icon-size" /> - + )}