Merge branch 'development' of https://github.com/esteemapp/esteem-mobile into new/wallet

This commit is contained in:
ue 2019-11-17 14:08:47 +03:00
commit ce36575f23
3 changed files with 44 additions and 37 deletions

View File

@ -32,4 +32,7 @@ export default EStyleSheet.create({
width: 193, width: 193,
height: 189, height: 189,
}, },
placeholderWrapper: {
flex: 1,
},
}); });

View File

@ -51,6 +51,9 @@ const PostsView = ({
const [isNoPost, setIsNoPost] = useState(false); const [isNoPost, setIsNoPost] = useState(false);
const [promotedPosts, setPromotedPosts] = useState([]); const [promotedPosts, setPromotedPosts] = useState([]);
const [scrollOffsetY, setScrollOffsetY] = useState(0); const [scrollOffsetY, setScrollOffsetY] = useState(0);
const [selectedFilterValue, setSelectedFilterValue] = useState(
filterOptionsValue && filterOptionsValue[selectedFilterIndex],
);
const intl = useIntl(); const intl = useIntl();
useEffect(() => { useEffect(() => {
@ -62,8 +65,6 @@ const PostsView = ({
}; };
fetchPromotePost(); fetchPromotePost();
_loadPosts(); _loadPosts();
setRefreshing(false);
setIsLoading(false);
} }
}, [ }, [
_getPromotePosts, _getPromotePosts,
@ -81,8 +82,6 @@ const PostsView = ({
setPosts([]); setPosts([]);
setStartAuthor(''); setStartAuthor('');
setStartPermlink(''); setStartPermlink('');
setRefreshing(false);
setIsLoading(false);
setSelectedFilterIndex(selectedOptionIndex || 0); setSelectedFilterIndex(selectedOptionIndex || 0);
setIsNoPost(false); setIsNoPost(false);
@ -102,20 +101,21 @@ const PostsView = ({
useEffect(() => { useEffect(() => {
if (!startAuthor && !startPermlink) { if (!startAuthor && !startPermlink) {
_loadPosts( _loadPosts(selectedFilterValue);
filterOptions && filterOptions.length > 0 && filterOptionsValue[selectedFilterIndex],
);
} }
}, [ }, [
_loadPosts, _loadPosts,
filterOptions, filterOptions,
filterOptionsValue, filterOptionsValue,
selectedFilterIndex, selectedFilterValue,
startAuthor, startAuthor,
startPermlink, startPermlink,
]); ]);
const _handleOnDropdownSelect = async index => { const _handleOnDropdownSelect = async index => {
if (filterOptions && filterOptions.length > 0) {
await setSelectedFilterValue(filterOptionsValue[index]);
}
setSelectedFilterIndex(index); setSelectedFilterIndex(index);
setPosts([]); setPosts([]);
setStartPermlink(''); setStartPermlink('');
@ -145,25 +145,26 @@ const PostsView = ({
}, [currentAccountUsername]); }, [currentAccountUsername]);
const _loadPosts = useCallback( const _loadPosts = useCallback(
async type => { type => {
if (isLoading) { if (
isLoading ||
!isConnected ||
(!isLoggedIn && type === 'feed') ||
(!isLoggedIn && type === 'blog')
) {
return; return;
} else {
setIsLoading(true);
} }
const filter = if (!isConnected && (refreshing || isLoading)) {
type ||
(filterOptions && filterOptions.length > 0 && filterOptionsValue[selectedFilterIndex]);
let options;
const limit = 3;
if (!isConnected) {
setRefreshing(false); setRefreshing(false);
setIsLoading(false); setIsLoading(false);
return null; return;
} }
const filter = type || selectedFilterValue;
let options;
const limit = 3;
if (filter === 'feed' || filter === 'blog' || getFor === 'blog' || filter === 'reblogs') { if (filter === 'feed' || filter === 'blog' || getFor === 'blog' || filter === 'reblogs') {
options = { options = {
tag, tag,
@ -202,7 +203,7 @@ const PostsView = ({
} }
} }
if (posts.length < 5) { if (posts.length < 5 && pageType !== 'profiles') {
setFeedPosts(_posts); setFeedPosts(_posts);
} }
@ -233,8 +234,7 @@ const PostsView = ({
} }
// Promoted post end // Promoted post end
if (refreshing) { if (!refreshing) {
} else if (!refreshing) {
setStartAuthor(result[result.length - 1] && result[result.length - 1].author); setStartAuthor(result[result.length - 1] && result[result.length - 1].author);
setStartPermlink(result[result.length - 1] && result[result.length - 1].permlink); setStartPermlink(result[result.length - 1] && result[result.length - 1].permlink);
} }
@ -252,16 +252,16 @@ const PostsView = ({
}, },
[ [
currentAccountUsername, currentAccountUsername,
filterOptions,
filterOptionsValue,
getFor, getFor,
isConnected, isConnected,
isLoading, isLoading,
isLoggedIn,
nsfw, nsfw,
pageType,
posts, posts,
promotedPosts, promotedPosts,
refreshing, refreshing,
selectedFilterIndex, selectedFilterValue,
setFeedPosts, setFeedPosts,
startAuthor, startAuthor,
startPermlink, startPermlink,
@ -295,7 +295,7 @@ const PostsView = ({
}; };
const _renderEmptyContent = () => { const _renderEmptyContent = () => {
if (getFor === 'feed' && isLoginDone && !isLoggedIn) { if ((selectedFilterValue === 'feed' || selectedFilterValue === 'blog') && !isLoggedIn) {
return ( return (
<NoPost <NoPost
imageStyle={styles.noImage} imageStyle={styles.noImage}
@ -324,10 +324,10 @@ const PostsView = ({
} }
return ( return (
<Fragment> <View style={styles.placeholderWrapper}>
<PostCardPlaceHolder /> <PostCardPlaceHolder />
<PostCardPlaceHolder /> <PostCardPlaceHolder />
</Fragment> </View>
); );
}; };
@ -369,7 +369,7 @@ const PostsView = ({
) )
} }
keyExtractor={(content, i) => `${get(content, 'permlink', '')}${i.toString()}`} keyExtractor={(content, i) => `${get(content, 'permlink', '')}${i.toString()}`}
onEndReached={_loadPosts} onEndReached={() => _loadPosts()}
removeClippedSubviews removeClippedSubviews
refreshing={refreshing} refreshing={refreshing}
onRefresh={_handleOnRefreshPosts} onRefresh={_handleOnRefreshPosts}

View File

@ -213,12 +213,16 @@ class UpvoteView extends Component {
} = this.props; } = this.props;
const { isVoting, amount, sliderValue, isVoted, isShowDetails, downvote } = this.state; const { isVoting, amount, sliderValue, isVoted, isShowDetails, downvote } = this.state;
let iconName = 'ios-arrow-dropup'; let iconName = 'upcircleo';
let iconType; let iconType = 'AntDesign';
let downVoteIconName = 'downcircleo';
if (isVoted) { if (isVoted) {
iconName = 'upcircle'; iconName = 'upcircle';
iconType = 'AntDesign'; }
if (isDownVoted) {
downVoteIconName = 'downcircle';
} }
const _percent = `${downvote ? '-' : ''}${(sliderValue * 100).toFixed(0)}%`; const _percent = `${downvote ? '-' : ''}${(sliderValue * 100).toFixed(0)}%`;
@ -253,8 +257,8 @@ class UpvoteView extends Component {
<Icon <Icon
style={[styles.upvoteIcon, isDownVoted && { color: '#ec8b88' }]} style={[styles.upvoteIcon, isDownVoted && { color: '#ec8b88' }]}
active={!isLoggedIn} active={!isLoggedIn}
iconType={isDownVoted ? 'AntDesign' : iconType} iconType={iconType}
name={isDownVoted ? 'downcircle' : iconName} name={isDownVoted ? downVoteIconName : iconName}
/> />
</View> </View>
)} )}
@ -328,7 +332,7 @@ class UpvoteView extends Component {
size={20} size={20}
style={[styles.upvoteIcon, { color: '#007ee5' }]} style={[styles.upvoteIcon, { color: '#007ee5' }]}
active={!isLoggedIn} active={!isLoggedIn}
iconType={iconType} iconType="AntDesign"
name={iconName} name={iconName}
/> />
</TouchableOpacity> </TouchableOpacity>
@ -356,7 +360,7 @@ class UpvoteView extends Component {
style={[styles.upvoteIcon, { color: '#ec8b88' }]} style={[styles.upvoteIcon, { color: '#ec8b88' }]}
active={!isLoggedIn} active={!isLoggedIn}
iconType="AntDesign" iconType="AntDesign"
name="downcircle" name={downVoteIconName}
/> />
</TouchableOpacity> </TouchableOpacity>
</Fragment> </Fragment>