mirror of
https://github.com/ecency/ecency-mobile.git
synced 2025-01-04 20:15:51 +03:00
Merge pull request #315 from esteemapp/profile-page
DONT MERGE YET: no_image upd, posts filter fix on list and profile page
This commit is contained in:
commit
b440556a10
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 { POPULAR_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);
|
||||
|
||||
this.state = {
|
||||
posts: [],
|
||||
startAuthor: '',
|
||||
@ -29,7 +30,7 @@ class PostsView extends Component {
|
||||
isLoading: false,
|
||||
isPostsLoading: true,
|
||||
isHideImage: false,
|
||||
selectedFilterIndex: 0,
|
||||
selectedFilterIndex: props.selectedOptionIndex || 0,
|
||||
isNoPost: false,
|
||||
};
|
||||
}
|
||||
@ -79,25 +80,36 @@ 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'
|
||||
? POPULAR_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,
|
||||
};
|
||||
// TODO: implement filtering of reblogs on `blog` and `feed` posts
|
||||
if (filter == 'reblogs') {
|
||||
options = {
|
||||
tag,
|
||||
limit: 3,
|
||||
};
|
||||
} else {
|
||||
options = {
|
||||
limit: 3,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (startAuthor && startPermlink && !refreshing) {
|
||||
@ -110,9 +122,18 @@ class PostsView extends Component {
|
||||
if (result.length > 0) {
|
||||
let _posts = result;
|
||||
|
||||
if (filter === 'reblogs') {
|
||||
for (let 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 {
|
||||
@ -215,6 +236,7 @@ class PostsView extends Component {
|
||||
} = this.state;
|
||||
const {
|
||||
filterOptions,
|
||||
selectedOptionIndex,
|
||||
intl,
|
||||
isLoggedIn,
|
||||
getFor,
|
||||
@ -229,8 +251,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,10 +260,9 @@ class PostsView extends Component {
|
||||
/>
|
||||
)}
|
||||
<Fragment>
|
||||
{filters[selectedFilterIndex] === 'feed'
|
||||
&& getFor === 'feed'
|
||||
&& !isLoggedIn
|
||||
&& isLoginDone && (
|
||||
{ getFor === 'feed'
|
||||
&& isLoginDone
|
||||
&& !isLoggedIn && (
|
||||
<NoPost
|
||||
imageStyle={styles.noImage}
|
||||
isButtonText
|
||||
|
2
src/constants/options/filters.js
Normal file
2
src/constants/options/filters.js
Normal file
@ -0,0 +1,2 @@
|
||||
export const POPULAR_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,8 @@ import { Header } from '../../../components/header';
|
||||
// Styles
|
||||
import styles from './homeStyles';
|
||||
|
||||
import { POPULAR_FILTERS, PROFILE_FILTERS } from '../../../constants/options/filters';
|
||||
|
||||
class HomeScreen extends PureComponent {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
@ -22,22 +24,8 @@ class HomeScreen extends PureComponent {
|
||||
const {
|
||||
currentAccount, intl, isLoggedIn, isLoginDone,
|
||||
} = this.props;
|
||||
const _filterOptions = [
|
||||
'NEW POSTS',
|
||||
'TRENDING',
|
||||
'HOT',
|
||||
'NEW',
|
||||
'ACTIVE',
|
||||
'PROMOTED',
|
||||
'VOTES',
|
||||
'COMMENTS',
|
||||
'PAYOUT',
|
||||
];
|
||||
let tag;
|
||||
|
||||
if (isLoginDone && !isLoggedIn) {
|
||||
// tag = 'esteemapp';
|
||||
}
|
||||
let tag;
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
@ -62,9 +50,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 +63,12 @@ class HomeScreen extends PureComponent {
|
||||
})}
|
||||
style={styles.tabbarItem}
|
||||
>
|
||||
<Posts filterOptions={_filterOptions} getFor="trending" />
|
||||
<Posts
|
||||
filterOptions={POPULAR_FILTERS}
|
||||
getFor={POPULAR_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