Merge pull request #1885 from ecency/details-timout-fix

removed timeout - using post body loading flag to render footer content
This commit is contained in:
Feruz M 2021-03-30 17:58:40 +03:00 committed by GitHub
commit 78df426cc4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 16 deletions

View File

@ -31,6 +31,7 @@ const PostBody = ({
handleOnUserPress,
handleOnPostPress,
dispatch,
onLoadEnd,
}) => {
const [isImageModalOpen, setIsImageModalOpen] = useState(false);
const [postImages, setPostImages] = useState([]);
@ -41,7 +42,7 @@ const PostBody = ({
const intl = useIntl();
const actionImage = useRef(null);
const actionLink = useRef(null);
const [isLoading, setIsLoading] = useState(true);
// const [isLoading, setIsLoading] = useState(true);
useEffect(() => {
if (selectedLink) {
@ -294,9 +295,9 @@ const PostBody = ({
};
const _handleLoadEnd = () => {
setTimeout(() => {
setIsLoading(false);
}, 200);
if (onLoadEnd) {
onLoadEnd();
}
};
const customStyle = `
@ -461,7 +462,7 @@ const PostBody = ({
handleLinkPress(index);
}}
/>
{isLoading && (isComment ? <CommentPlaceHolder /> : <PostPlaceHolder />)}
{/* {isLoading && (isComment ? <CommentPlaceHolder /> : <PostPlaceHolder />)} */}
<AutoHeightWebView
source={{ html }}
allowsFullscreenVideo={true}
@ -470,6 +471,7 @@ const PostBody = ({
onMessage={_handleOnLinkPress}
customScript={customBodyScript}
startInLoadingState={true}
renderLoading={() => (isComment ? <CommentPlaceHolder /> : <PostPlaceHolder />)}
onShouldStartLoadWithRequest={false}
scrollEnabled={false}
scalesPageToFit={false}

View File

@ -48,6 +48,7 @@ const PostDisplayView = ({
const [isLoadedComments, setIsLoadedComments] = useState(false);
const actionSheet = useRef(null);
const [refreshing, setRefreshing] = useState(false);
const [postBodyLoading, setPostBodyLoading] = useState(false);
// Component Life Cycles
useEffect(() => {
@ -59,6 +60,7 @@ const PostDisplayView = ({
// Component Functions
const onRefresh = useCallback(() => {
setRefreshing(true);
setPostBodyLoading(true);
fetchPost().then(() => setRefreshing(false));
}, [refreshing]);
@ -183,6 +185,10 @@ const PostDisplayView = ({
);
}
const _handleOnPostBodyLoad = () => {
setPostBodyLoading(false);
};
return (
<View style={styles.container}>
<ScrollView
@ -207,20 +213,22 @@ const PostDisplayView = ({
content={post}
size={36}
/>
<PostBody body={post.body} />
<View style={styles.footer}>
<Tags tags={post.json_metadata && post.json_metadata.tags} />
<Text style={styles.footerText}>
Posted by
<Text style={styles.footerName}>{` ${author || post.author} `}</Text>
{formatedTime}
</Text>
{/* {isPostEnd && this._getTabBar()} */}
</View>
<PostBody body={post.body} onLoadEnd={_handleOnPostBodyLoad} />
{!postBodyLoading && (
<View style={styles.footer}>
<Tags tags={post.json_metadata && post.json_metadata.tags} />
<Text style={styles.footerText}>
Posted by
<Text style={styles.footerName}>{` ${author || post.author} `}</Text>
{formatedTime}
</Text>
{/* {isPostEnd && this._getTabBar()} */}
</View>
)}
</View>
)}
</View>
{post && (isGetComment || isLoadedComments) && (
{post && !postBodyLoading && (isGetComment || isLoadedComments) && (
<CommentsDisplay
author={author || post.author}
mainAuthor={author || post.author}