mirror of
https://github.com/ecency/ecency-mobile.git
synced 2025-01-05 04:28:03 +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 {
|
const {
|
||||||
author, permlink, commentCount, fetchPost,
|
author, permlink, commentCount, fetchPost,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
//TODO: implement comments filtering
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
{commentCount > 0 && (
|
{commentCount > 0 && (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<FilterBar
|
<FilterBar
|
||||||
dropdownIconName="arrow-drop-down"
|
dropdownIconName="arrow-drop-down"
|
||||||
options={['NEW COMMENTS']}
|
options={['TRENDING']}
|
||||||
defaultText="NEW COMMENTS"
|
defaultText="TRENDING"
|
||||||
onDropdownSelect={this._handleOnDropdownSelect}
|
onDropdownSelect={this._handleOnDropdownSelect}
|
||||||
/>
|
/>
|
||||||
<View style={{ padding: 16 }}>
|
<View style={{ padding: 16 }}>
|
||||||
|
@ -22,6 +22,7 @@ const FilterBarView = ({
|
|||||||
iconSize,
|
iconSize,
|
||||||
isHide,
|
isHide,
|
||||||
onDropdownSelect,
|
onDropdownSelect,
|
||||||
|
pageType,
|
||||||
onRightIconPress,
|
onRightIconPress,
|
||||||
options,
|
options,
|
||||||
rightIconName,
|
rightIconName,
|
||||||
|
@ -12,8 +12,8 @@ import { getPostsSummary } from '../../../providers/steem/dsteem';
|
|||||||
import { PostCard } from '../../postCard';
|
import { PostCard } from '../../postCard';
|
||||||
import { FilterBar } from '../../filterBar';
|
import { FilterBar } from '../../filterBar';
|
||||||
import { PostCardPlaceHolder, NoPost } from '../../basicUIElements';
|
import { PostCardPlaceHolder, NoPost } from '../../basicUIElements';
|
||||||
|
import {filters, profile_filters} from '../../../constants/options/filters';
|
||||||
|
|
||||||
import filters from '../../../constants/options/filters.json';
|
|
||||||
// Styles
|
// Styles
|
||||||
import styles from './postsStyles';
|
import styles from './postsStyles';
|
||||||
import { default as ROUTES } from '../../../constants/routeNames';
|
import { default as ROUTES } from '../../../constants/routeNames';
|
||||||
@ -21,6 +21,7 @@ import { default as ROUTES } from '../../../constants/routeNames';
|
|||||||
class PostsView extends Component {
|
class PostsView extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
const { selectedOptionIndex } = this.props;
|
||||||
this.state = {
|
this.state = {
|
||||||
posts: [],
|
posts: [],
|
||||||
startAuthor: '',
|
startAuthor: '',
|
||||||
@ -29,7 +30,7 @@ class PostsView extends Component {
|
|||||||
isLoading: false,
|
isLoading: false,
|
||||||
isPostsLoading: true,
|
isPostsLoading: true,
|
||||||
isHideImage: false,
|
isHideImage: false,
|
||||||
selectedFilterIndex: 0,
|
selectedFilterIndex: selectedOptionIndex||0,
|
||||||
isNoPost: false,
|
isNoPost: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -79,25 +80,32 @@ class PostsView extends Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
_loadPosts = () => {
|
_loadPosts = () => {
|
||||||
const { getFor, tag, currentAccountUsername } = this.props;
|
|
||||||
|
const { getFor, tag, currentAccountUsername, pageType } = this.props;
|
||||||
const {
|
const {
|
||||||
posts, startAuthor, startPermlink, refreshing, selectedFilterIndex,
|
posts, startAuthor, startPermlink, refreshing, selectedFilterIndex,
|
||||||
} = this.state;
|
} = this.state;
|
||||||
const filter = selectedFilterIndex !== 0 ? filters[selectedFilterIndex] : getFor;
|
const filter = pageType === 'posts' ? filters[selectedFilterIndex].toLowerCase() : profile_filters[selectedFilterIndex].toLowerCase();
|
||||||
let options;
|
let options;
|
||||||
let newPosts = [];
|
let newPosts = [];
|
||||||
|
|
||||||
this.setState({ isLoading: true });
|
this.setState({ isLoading: true });
|
||||||
|
if ((!filter && tag) || filter === 'feed' || filter === 'blog' || getFor === 'blog') {
|
||||||
if ((!filter && tag) || filter === 'feed' || getFor === 'blog') {
|
|
||||||
options = {
|
options = {
|
||||||
tag,
|
tag,
|
||||||
limit: 3,
|
limit: 3,
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
options = {
|
if (filter=='reblogs'){
|
||||||
limit: 3,
|
options = {
|
||||||
};
|
tag,
|
||||||
|
limit: 3,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
options = {
|
||||||
|
limit: 3,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (startAuthor && startPermlink && !refreshing) {
|
if (startAuthor && startPermlink && !refreshing) {
|
||||||
@ -110,9 +118,18 @@ class PostsView extends Component {
|
|||||||
if (result.length > 0) {
|
if (result.length > 0) {
|
||||||
let _posts = result;
|
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 (posts.length > 0) {
|
if (posts.length > 0) {
|
||||||
if (refreshing) {
|
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));
|
newPosts = _posts.filter(post => posts.includes(post));
|
||||||
_posts = [...newPosts, ...posts];
|
_posts = [...newPosts, ...posts];
|
||||||
} else {
|
} else {
|
||||||
@ -126,6 +143,7 @@ class PostsView extends Component {
|
|||||||
posts: _posts,
|
posts: _posts,
|
||||||
});
|
});
|
||||||
} else if (!refreshing) {
|
} else if (!refreshing) {
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
posts: _posts,
|
posts: _posts,
|
||||||
startAuthor: result[result.length - 1] && result[result.length - 1].author,
|
startAuthor: result[result.length - 1] && result[result.length - 1].author,
|
||||||
@ -215,6 +233,7 @@ class PostsView extends Component {
|
|||||||
} = this.state;
|
} = this.state;
|
||||||
const {
|
const {
|
||||||
filterOptions,
|
filterOptions,
|
||||||
|
selectedOptionIndex,
|
||||||
intl,
|
intl,
|
||||||
isLoggedIn,
|
isLoggedIn,
|
||||||
getFor,
|
getFor,
|
||||||
@ -229,8 +248,8 @@ class PostsView extends Component {
|
|||||||
<FilterBar
|
<FilterBar
|
||||||
dropdownIconName="arrow-drop-down"
|
dropdownIconName="arrow-drop-down"
|
||||||
options={filterOptions}
|
options={filterOptions}
|
||||||
selectedOptionIndex={0}
|
selectedOptionIndex={selectedOptionIndex}
|
||||||
defaultText={filterOptions[0]}
|
defaultText={filterOptions[selectedOptionIndex]}
|
||||||
rightIconName="view-module"
|
rightIconName="view-module"
|
||||||
rightIconType="MaterialIcons"
|
rightIconType="MaterialIcons"
|
||||||
onDropdownSelect={this._handleOnDropdownSelect}
|
onDropdownSelect={this._handleOnDropdownSelect}
|
||||||
@ -238,7 +257,7 @@ class PostsView extends Component {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<Fragment>
|
<Fragment>
|
||||||
{filters[selectedFilterIndex] === 'feed'
|
{profile_filters[selectedFilterIndex] === 'feed'
|
||||||
&& getFor === 'feed'
|
&& getFor === 'feed'
|
||||||
&& !isLoggedIn
|
&& !isLoggedIn
|
||||||
&& isLoginDone && (
|
&& 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
|
// Styles
|
||||||
import styles from './homeStyles';
|
import styles from './homeStyles';
|
||||||
|
|
||||||
|
import {filters, profile_filters} from '../../../constants/options/filters';
|
||||||
|
|
||||||
|
|
||||||
class HomeScreen extends PureComponent {
|
class HomeScreen extends PureComponent {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
@ -33,6 +36,7 @@ class HomeScreen extends PureComponent {
|
|||||||
'COMMENTS',
|
'COMMENTS',
|
||||||
'PAYOUT',
|
'PAYOUT',
|
||||||
];
|
];
|
||||||
|
|
||||||
let tag;
|
let tag;
|
||||||
|
|
||||||
if (isLoginDone && !isLoggedIn) {
|
if (isLoginDone && !isLoggedIn) {
|
||||||
@ -62,9 +66,11 @@ class HomeScreen extends PureComponent {
|
|||||||
style={styles.tabbarItem}
|
style={styles.tabbarItem}
|
||||||
>
|
>
|
||||||
<Posts
|
<Posts
|
||||||
filterOptions={_filterOptions}
|
filterOptions={profile_filters}
|
||||||
getFor="feed"
|
getFor={profile_filters[1].toLowerCase()}
|
||||||
tag={tag || currentAccount.name}
|
tag={tag || currentAccount.name}
|
||||||
|
selectedOptionIndex={1}
|
||||||
|
pageType="profiles"
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
<View
|
<View
|
||||||
@ -73,7 +79,7 @@ class HomeScreen extends PureComponent {
|
|||||||
})}
|
})}
|
||||||
style={styles.tabbarItem}
|
style={styles.tabbarItem}
|
||||||
>
|
>
|
||||||
<Posts filterOptions={_filterOptions} getFor="trending" />
|
<Posts filterOptions={filters} getFor={filters[0].toLowerCase()} selectedOptionIndex={0} pageType="posts" />
|
||||||
</View>
|
</View>
|
||||||
</ScrollableTabView>
|
</ScrollableTabView>
|
||||||
</View>
|
</View>
|
||||||
|
@ -12,6 +12,7 @@ import { Posts } from '../../../components/posts';
|
|||||||
import { ProfileSummary } from '../../../components/profileSummary';
|
import { ProfileSummary } from '../../../components/profileSummary';
|
||||||
import { TabBar } from '../../../components/tabBar';
|
import { TabBar } from '../../../components/tabBar';
|
||||||
import { Wallet } from '../../../components/wallet';
|
import { Wallet } from '../../../components/wallet';
|
||||||
|
import {profile_filters} from '../../../constants/options/filters';
|
||||||
|
|
||||||
// Utilitites
|
// Utilitites
|
||||||
import { getFormatedCreatedDate } from '../../../utils/time';
|
import { getFormatedCreatedDate } from '../../../utils/time';
|
||||||
@ -25,7 +26,7 @@ class ProfileScreen extends PureComponent {
|
|||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
isSummaryOpen: true,
|
isSummaryOpen: true,
|
||||||
collapsibleMoreHeight: 0,
|
collapsibleMoreHeight: 0
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,7 +66,11 @@ class ProfileScreen extends PureComponent {
|
|||||||
user,
|
user,
|
||||||
username,
|
username,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
const { isSummaryOpen, collapsibleMoreHeight } = this.state;
|
const { isSummaryOpen, collapsibleMoreHeight } = this.state;
|
||||||
|
|
||||||
|
let filters=profile_filters;
|
||||||
|
|
||||||
let _about;
|
let _about;
|
||||||
let coverImage;
|
let coverImage;
|
||||||
let location;
|
let location;
|
||||||
@ -151,7 +156,9 @@ class ProfileScreen extends PureComponent {
|
|||||||
style={styles.postTabBar}
|
style={styles.postTabBar}
|
||||||
>
|
>
|
||||||
<Posts
|
<Posts
|
||||||
filterOptions={['NEW POSTS', 'VOTES', 'REPLIES', 'MENTIONS', 'FOLLOWS', 'REBLOGS']}
|
filterOptions={filters}
|
||||||
|
selectedOptionIndex={0}
|
||||||
|
pageType="profiles"
|
||||||
getFor="blog"
|
getFor="blog"
|
||||||
tag={username}
|
tag={username}
|
||||||
key={username}
|
key={username}
|
||||||
|
@ -79,7 +79,7 @@ const postImage = (metaData, body) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (imageLink) {
|
if (imageLink) {
|
||||||
return `https://img.esteem.app/600x0/${imageLink}`;
|
return `https://steemitimages.com/600x0/${imageLink}`;
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user