diff --git a/src/components/posts/view/postsStyles.js b/src/components/posts/view/postsStyles.js index 9e5fad34f..a7e75b567 100644 --- a/src/components/posts/view/postsStyles.js +++ b/src/components/posts/view/postsStyles.js @@ -32,4 +32,7 @@ export default EStyleSheet.create({ width: 193, height: 189, }, + placeholderWrapper: { + flex: 1, + }, }); diff --git a/src/components/posts/view/postsView.js b/src/components/posts/view/postsView.js index 3f45974fd..53d1f02bb 100644 --- a/src/components/posts/view/postsView.js +++ b/src/components/posts/view/postsView.js @@ -51,6 +51,9 @@ const PostsView = ({ const [isNoPost, setIsNoPost] = useState(false); const [promotedPosts, setPromotedPosts] = useState([]); const [scrollOffsetY, setScrollOffsetY] = useState(0); + const [selectedFilterValue, setSelectedFilterValue] = useState( + filterOptionsValue && filterOptionsValue[selectedFilterIndex], + ); const intl = useIntl(); useEffect(() => { @@ -62,8 +65,6 @@ const PostsView = ({ }; fetchPromotePost(); _loadPosts(); - setRefreshing(false); - setIsLoading(false); } }, [ _getPromotePosts, @@ -81,8 +82,6 @@ const PostsView = ({ setPosts([]); setStartAuthor(''); setStartPermlink(''); - setRefreshing(false); - setIsLoading(false); setSelectedFilterIndex(selectedOptionIndex || 0); setIsNoPost(false); @@ -102,20 +101,21 @@ const PostsView = ({ useEffect(() => { if (!startAuthor && !startPermlink) { - _loadPosts( - filterOptions && filterOptions.length > 0 && filterOptionsValue[selectedFilterIndex], - ); + _loadPosts(selectedFilterValue); } }, [ _loadPosts, filterOptions, filterOptionsValue, - selectedFilterIndex, + selectedFilterValue, startAuthor, startPermlink, ]); const _handleOnDropdownSelect = async index => { + if (filterOptions && filterOptions.length > 0) { + await setSelectedFilterValue(filterOptionsValue[index]); + } setSelectedFilterIndex(index); setPosts([]); setStartPermlink(''); @@ -145,25 +145,26 @@ const PostsView = ({ }, [currentAccountUsername]); const _loadPosts = useCallback( - async type => { - if (isLoading) { + type => { + if ( + isLoading || + !isConnected || + (!isLoggedIn && type === 'feed') || + (!isLoggedIn && type === 'blog') + ) { return; - } else { - setIsLoading(true); } - const filter = - type || - (filterOptions && filterOptions.length > 0 && filterOptionsValue[selectedFilterIndex]); - let options; - const limit = 3; - - if (!isConnected) { + if (!isConnected && (refreshing || isLoading)) { setRefreshing(false); setIsLoading(false); - return null; + return; } + const filter = type || selectedFilterValue; + let options; + const limit = 3; + if (filter === 'feed' || filter === 'blog' || getFor === 'blog' || filter === 'reblogs') { options = { tag, @@ -202,7 +203,7 @@ const PostsView = ({ } } - if (posts.length < 5) { + if (posts.length < 5 && pageType !== 'profiles') { setFeedPosts(_posts); } @@ -233,8 +234,7 @@ const PostsView = ({ } // Promoted post end - if (refreshing) { - } else if (!refreshing) { + if (!refreshing) { setStartAuthor(result[result.length - 1] && result[result.length - 1].author); setStartPermlink(result[result.length - 1] && result[result.length - 1].permlink); } @@ -252,16 +252,16 @@ const PostsView = ({ }, [ currentAccountUsername, - filterOptions, - filterOptionsValue, getFor, isConnected, isLoading, + isLoggedIn, nsfw, + pageType, posts, promotedPosts, refreshing, - selectedFilterIndex, + selectedFilterValue, setFeedPosts, startAuthor, startPermlink, @@ -295,7 +295,7 @@ const PostsView = ({ }; const _renderEmptyContent = () => { - if (getFor === 'feed' && isLoginDone && !isLoggedIn) { + if ((selectedFilterValue === 'feed' || selectedFilterValue === 'blog') && !isLoggedIn) { return ( + - + ); }; @@ -369,7 +369,7 @@ const PostsView = ({ ) } keyExtractor={(content, i) => `${get(content, 'permlink', '')}${i.toString()}`} - onEndReached={_loadPosts} + onEndReached={() => _loadPosts()} removeClippedSubviews refreshing={refreshing} onRefresh={_handleOnRefreshPosts} diff --git a/src/components/upvote/view/upvoteView.js b/src/components/upvote/view/upvoteView.js index db3028b63..695aac5fc 100644 --- a/src/components/upvote/view/upvoteView.js +++ b/src/components/upvote/view/upvoteView.js @@ -213,12 +213,16 @@ class UpvoteView extends Component { } = this.props; const { isVoting, amount, sliderValue, isVoted, isShowDetails, downvote } = this.state; - let iconName = 'ios-arrow-dropup'; - let iconType; + let iconName = 'upcircleo'; + let iconType = 'AntDesign'; + let downVoteIconName = 'downcircleo'; if (isVoted) { iconName = 'upcircle'; - iconType = 'AntDesign'; + } + + if (isDownVoted) { + downVoteIconName = 'downcircle'; } const _percent = `${downvote ? '-' : ''}${(sliderValue * 100).toFixed(0)}%`; @@ -253,8 +257,8 @@ class UpvoteView extends Component { )} @@ -328,7 +332,7 @@ class UpvoteView extends Component { size={20} style={[styles.upvoteIcon, { color: '#007ee5' }]} active={!isLoggedIn} - iconType={iconType} + iconType="AntDesign" name={iconName} /> @@ -356,7 +360,7 @@ class UpvoteView extends Component { style={[styles.upvoteIcon, { color: '#ec8b88' }]} active={!isLoggedIn} iconType="AntDesign" - name="downcircle" + name={downVoteIconName} />