mirror of
https://github.com/ecency/ecency-mobile.git
synced 2025-01-03 03:25:24 +03:00
no_image upd, posts filter fix on list and profile page
This commit is contained in:
parent
cdb67bc627
commit
047ef068f5
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 2.5 KiB |
@ -32,15 +32,15 @@ class CommentsDisplayView extends PureComponent {
|
||||
const {
|
||||
author, permlink, commentCount, fetchPost,
|
||||
} = this.props;
|
||||
|
||||
//TODO: implement comments filtering
|
||||
return (
|
||||
<Fragment>
|
||||
{commentCount > 0 && (
|
||||
<Fragment>
|
||||
<FilterBar
|
||||
dropdownIconName="arrow-drop-down"
|
||||
options={['NEW COMMENTS']}
|
||||
defaultText="NEW COMMENTS"
|
||||
options={['TRENDING']}
|
||||
defaultText="TRENDING"
|
||||
onDropdownSelect={this._handleOnDropdownSelect}
|
||||
/>
|
||||
<View style={{ padding: 16 }}>
|
||||
|
@ -22,6 +22,7 @@ const FilterBarView = ({
|
||||
iconSize,
|
||||
isHide,
|
||||
onDropdownSelect,
|
||||
pageType,
|
||||
onRightIconPress,
|
||||
options,
|
||||
rightIconName,
|
||||
|
@ -12,8 +12,8 @@ import { getPostsSummary } from '../../../providers/steem/dsteem';
|
||||
import { PostCard } from '../../postCard';
|
||||
import { FilterBar } from '../../filterBar';
|
||||
import { PostCardPlaceHolder, NoPost } from '../../basicUIElements';
|
||||
import {filters, profile_filters} from '../../../constants/options/filters';
|
||||
|
||||
import filters from '../../../constants/options/filters.json';
|
||||
// Styles
|
||||
import styles from './postsStyles';
|
||||
import { default as ROUTES } from '../../../constants/routeNames';
|
||||
@ -21,6 +21,7 @@ import { default as ROUTES } from '../../../constants/routeNames';
|
||||
class PostsView extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
const { selectedOptionIndex } = this.props;
|
||||
this.state = {
|
||||
posts: [],
|
||||
startAuthor: '',
|
||||
@ -29,7 +30,7 @@ class PostsView extends Component {
|
||||
isLoading: false,
|
||||
isPostsLoading: true,
|
||||
isHideImage: false,
|
||||
selectedFilterIndex: 0,
|
||||
selectedFilterIndex: selectedOptionIndex||0,
|
||||
isNoPost: false,
|
||||
};
|
||||
}
|
||||
@ -79,25 +80,32 @@ class PostsView extends Component {
|
||||
};
|
||||
|
||||
_loadPosts = () => {
|
||||
const { getFor, tag, currentAccountUsername } = this.props;
|
||||
|
||||
const { getFor, tag, currentAccountUsername, pageType } = this.props;
|
||||
const {
|
||||
posts, startAuthor, startPermlink, refreshing, selectedFilterIndex,
|
||||
} = this.state;
|
||||
const filter = selectedFilterIndex !== 0 ? filters[selectedFilterIndex] : getFor;
|
||||
const filter = pageType === 'posts' ? filters[selectedFilterIndex].toLowerCase() : profile_filters[selectedFilterIndex].toLowerCase();
|
||||
let options;
|
||||
let newPosts = [];
|
||||
|
||||
this.setState({ isLoading: true });
|
||||
|
||||
if ((!filter && tag) || filter === 'feed' || getFor === 'blog') {
|
||||
if ((!filter && tag) || filter === 'feed' || filter === 'blog' || getFor === 'blog') {
|
||||
options = {
|
||||
tag,
|
||||
limit: 3,
|
||||
};
|
||||
} else {
|
||||
options = {
|
||||
limit: 3,
|
||||
};
|
||||
if (filter=='reblogs'){
|
||||
options = {
|
||||
tag,
|
||||
limit: 3,
|
||||
};
|
||||
} else {
|
||||
options = {
|
||||
limit: 3,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (startAuthor && startPermlink && !refreshing) {
|
||||
@ -110,9 +118,18 @@ class PostsView extends Component {
|
||||
if (result.length > 0) {
|
||||
let _posts = result;
|
||||
|
||||
if (filter==='reblogs') {
|
||||
for (var i = _posts.length - 1; i >= 0; i--) {
|
||||
if (_posts[i].author === currentAccountUsername) {
|
||||
_posts.splice(i, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_posts.length > 0) {
|
||||
if (posts.length > 0) {
|
||||
if (refreshing) {
|
||||
//TODO: make sure post is not duplicated, because checking with `includes` might re-add post
|
||||
//if there was change in post object from blockchain
|
||||
newPosts = _posts.filter(post => posts.includes(post));
|
||||
_posts = [...newPosts, ...posts];
|
||||
} else {
|
||||
@ -126,6 +143,7 @@ class PostsView extends Component {
|
||||
posts: _posts,
|
||||
});
|
||||
} else if (!refreshing) {
|
||||
|
||||
this.setState({
|
||||
posts: _posts,
|
||||
startAuthor: result[result.length - 1] && result[result.length - 1].author,
|
||||
@ -215,6 +233,7 @@ class PostsView extends Component {
|
||||
} = this.state;
|
||||
const {
|
||||
filterOptions,
|
||||
selectedOptionIndex,
|
||||
intl,
|
||||
isLoggedIn,
|
||||
getFor,
|
||||
@ -229,8 +248,8 @@ class PostsView extends Component {
|
||||
<FilterBar
|
||||
dropdownIconName="arrow-drop-down"
|
||||
options={filterOptions}
|
||||
selectedOptionIndex={0}
|
||||
defaultText={filterOptions[0]}
|
||||
selectedOptionIndex={selectedOptionIndex}
|
||||
defaultText={filterOptions[selectedOptionIndex]}
|
||||
rightIconName="view-module"
|
||||
rightIconType="MaterialIcons"
|
||||
onDropdownSelect={this._handleOnDropdownSelect}
|
||||
@ -238,7 +257,7 @@ class PostsView extends Component {
|
||||
/>
|
||||
)}
|
||||
<Fragment>
|
||||
{filters[selectedFilterIndex] === 'feed'
|
||||
{profile_filters[selectedFilterIndex] === 'feed'
|
||||
&& getFor === 'feed'
|
||||
&& !isLoggedIn
|
||||
&& isLoginDone && (
|
||||
|
2
src/constants/options/filters.js
Normal file
2
src/constants/options/filters.js
Normal file
@ -0,0 +1,2 @@
|
||||
export const filters = ["TRENDING", "HOT", "CREATED", "ACTIVE", "PROMOTED", "VOTES", "CHILDREN"];
|
||||
export const profile_filters = ["BLOG","FEED"];
|
@ -1 +0,0 @@
|
||||
["feed", "trending", "hot", "created", "active", "promoted", "votes", "children"]
|
@ -12,6 +12,9 @@ import { Header } from '../../../components/header';
|
||||
// Styles
|
||||
import styles from './homeStyles';
|
||||
|
||||
import {filters, profile_filters} from '../../../constants/options/filters';
|
||||
|
||||
|
||||
class HomeScreen extends PureComponent {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
@ -33,6 +36,7 @@ class HomeScreen extends PureComponent {
|
||||
'COMMENTS',
|
||||
'PAYOUT',
|
||||
];
|
||||
|
||||
let tag;
|
||||
|
||||
if (isLoginDone && !isLoggedIn) {
|
||||
@ -62,9 +66,11 @@ class HomeScreen extends PureComponent {
|
||||
style={styles.tabbarItem}
|
||||
>
|
||||
<Posts
|
||||
filterOptions={_filterOptions}
|
||||
getFor="feed"
|
||||
filterOptions={profile_filters}
|
||||
getFor={profile_filters[1].toLowerCase()}
|
||||
tag={tag || currentAccount.name}
|
||||
selectedOptionIndex={1}
|
||||
pageType="profiles"
|
||||
/>
|
||||
</View>
|
||||
<View
|
||||
@ -73,7 +79,7 @@ class HomeScreen extends PureComponent {
|
||||
})}
|
||||
style={styles.tabbarItem}
|
||||
>
|
||||
<Posts filterOptions={_filterOptions} getFor="trending" />
|
||||
<Posts filterOptions={filters} getFor={filters[0].toLowerCase()} selectedOptionIndex={0} pageType="posts" />
|
||||
</View>
|
||||
</ScrollableTabView>
|
||||
</View>
|
||||
|
@ -12,6 +12,7 @@ import { Posts } from '../../../components/posts';
|
||||
import { ProfileSummary } from '../../../components/profileSummary';
|
||||
import { TabBar } from '../../../components/tabBar';
|
||||
import { Wallet } from '../../../components/wallet';
|
||||
import {profile_filters} from '../../../constants/options/filters';
|
||||
|
||||
// Utilitites
|
||||
import { getFormatedCreatedDate } from '../../../utils/time';
|
||||
@ -25,7 +26,7 @@ class ProfileScreen extends PureComponent {
|
||||
super(props);
|
||||
this.state = {
|
||||
isSummaryOpen: true,
|
||||
collapsibleMoreHeight: 0,
|
||||
collapsibleMoreHeight: 0
|
||||
};
|
||||
}
|
||||
|
||||
@ -65,7 +66,11 @@ class ProfileScreen extends PureComponent {
|
||||
user,
|
||||
username,
|
||||
} = this.props;
|
||||
|
||||
const { isSummaryOpen, collapsibleMoreHeight } = this.state;
|
||||
|
||||
let filters=profile_filters;
|
||||
|
||||
let _about;
|
||||
let coverImage;
|
||||
let location;
|
||||
@ -151,7 +156,9 @@ class ProfileScreen extends PureComponent {
|
||||
style={styles.postTabBar}
|
||||
>
|
||||
<Posts
|
||||
filterOptions={['NEW POSTS', 'VOTES', 'REPLIES', 'MENTIONS', 'FOLLOWS', 'REBLOGS']}
|
||||
filterOptions={filters}
|
||||
selectedOptionIndex={0}
|
||||
pageType="profiles"
|
||||
getFor="blog"
|
||||
tag={username}
|
||||
key={username}
|
||||
|
@ -79,7 +79,7 @@ const postImage = (metaData, body) => {
|
||||
}
|
||||
|
||||
if (imageLink) {
|
||||
return `https://img.esteem.app/600x0/${imageLink}`;
|
||||
return `https://steemitimages.com/600x0/${imageLink}`;
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user