Merge branch 'master' into bugfix/lint-fix

This commit is contained in:
uğur erdal 2019-02-22 14:01:32 +03:00 committed by GitHub
commit 25260a321c
20 changed files with 314 additions and 117 deletions

View File

@ -11,8 +11,6 @@ import { getComments } from '../../../providers/steem/dsteem';
// Constants // Constants
import { default as ROUTES } from '../../../constants/routeNames'; import { default as ROUTES } from '../../../constants/routeNames';
// Utilities
// Component // Component
import { CommentsView } from '..'; import { CommentsView } from '..';
@ -36,14 +34,89 @@ class CommentsContainer extends Component {
} }
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
const { commentCount } = this.props; const { commentCount, selectedFilter } = this.props;
if (nextProps.commentCount > commentCount) { if (nextProps.commentCount > commentCount) {
this._getComments(); this._getComments();
} }
if (selectedFilter !== nextProps.selectedFilter && nextProps.selectedFilter) {
const shortedComments = this._shortComments(nextProps.selectedFilter);
this.setState({ comments: shortedComments });
}
} }
// Component Functions // Component Functions
_shortComments = (sortOrder) => {
const { comments: parent } = this.state;
const allPayout = c => parseFloat(c.pending_payout_value.split(' ')[0])
+ parseFloat(c.total_payout_value.split(' ')[0])
+ parseFloat(c.curator_payout_value.split(' ')[0]);
const absNegative = a => a.net_rshares < 0;
const sortOrders = {
TRENDING: (a, b) => {
if (absNegative(a)) {
return 1;
}
if (absNegative(b)) {
return -1;
}
const apayout = allPayout(a);
const bpayout = allPayout(b);
if (apayout !== bpayout) {
return bpayout - apayout;
}
return 0;
},
REPUTATION: (a, b) => {
const keyA = a.author_reputation;
const keyB = b.author_reputation;
if (keyA > keyB) return -1;
if (keyA < keyB) return 1;
return 0;
},
VOTES: (a, b) => {
const keyA = a.net_votes;
const keyB = b.net_votes;
if (keyA > keyB) return -1;
if (keyA < keyB) return 1;
return 0;
},
AGE: (a, b) => {
if (absNegative(a)) {
return 1;
}
if (absNegative(b)) {
return -1;
}
const keyA = Date.parse(a.created);
const keyB = Date.parse(b.created);
if (keyA > keyB) return -1;
if (keyA < keyB) return 1;
return 0;
},
};
parent.sort(sortOrders[sortOrder]);
return parent;
};
_getComments = () => { _getComments = () => {
const { author, permlink } = this.props; const { author, permlink } = this.props;
@ -87,18 +160,19 @@ class CommentsContainer extends Component {
isLoggedIn, isLoggedIn,
commentCount, commentCount,
author, author,
permlink,
currentAccount, currentAccount,
commentNumber, commentNumber,
comments, comments,
fetchPost, fetchPost,
isShowMoreButton, isShowMoreButton,
selectedFilter,
selectedPermlink: _selectedPermlink, selectedPermlink: _selectedPermlink,
} = this.props; } = this.props;
return ( return (
<CommentsView <CommentsView
key={permlink} key={selectedFilter}
selectedFilter={selectedFilter}
selectedPermlink={_selectedPermlink || selectedPermlink} selectedPermlink={_selectedPermlink || selectedPermlink}
author={author} author={author}
isShowMoreButton={isShowMoreButton} isShowMoreButton={isShowMoreButton}
@ -109,7 +183,6 @@ class CommentsContainer extends Component {
handleOnEditPress={this._handleOnEditPress} handleOnEditPress={this._handleOnEditPress}
handleOnReplyPress={this._handleOnReplyPress} handleOnReplyPress={this._handleOnReplyPress}
isLoggedIn={isLoggedIn} isLoggedIn={isLoggedIn}
permlink={permlink}
fetchPost={fetchPost} fetchPost={fetchPost}
{...this.props} {...this.props}
/> />

View File

@ -1,5 +1,5 @@
import React, { PureComponent } from 'react'; import React, { PureComponent } from 'react';
import { View, FlatList } from 'react-native'; import { FlatList } from 'react-native';
// Components // Components
import { Comment } from '../../comment'; import { Comment } from '../../comment';
@ -21,49 +21,46 @@ class CommentsView extends PureComponent {
// Component Life Cycles // Component Life Cycles
// Component Functions // Component Functions
_handleOnDropdownSelect = () => {};
_keyExtractor = item => item.permlink; _keyExtractor = item => item.permlink;
render() { render() {
const { const {
avatarSize, avatarSize,
commentCount,
commentNumber, commentNumber,
comments, comments,
currentAccountUsername, currentAccountUsername,
fetchPost,
handleOnEditPress, handleOnEditPress,
handleOnReplyPress, handleOnReplyPress,
handleOnUserPress, handleOnUserPress,
isLoggedIn, isLoggedIn,
marginLeft,
isShowSubComments, isShowSubComments,
fetchPost, marginLeft,
commentCount,
} = this.props; } = this.props;
return ( return (
<FlatList <FlatList
data={comments} data={comments}
keyExtractor={this._keyExtractor} keyExtractor={this._keyExtractor}
renderItem={({ item, index }) => ( renderItem={({ item }) => (
<View key={index}>
<Comment <Comment
isShowMoreButton={commentNumber === 1 && item.children > 0}
comment={item}
marginLeft={marginLeft}
commentNumber={commentNumber}
fetchPost={fetchPost}
commentCount={commentCount || item.children}
isShowSubComments={isShowSubComments}
avatarSize={avatarSize} avatarSize={avatarSize}
comment={item}
commentCount={commentCount || item.children}
commentNumber={commentNumber}
currentAccountUsername={currentAccountUsername} currentAccountUsername={currentAccountUsername}
handleOnReplyPress={handleOnReplyPress} fetchPost={fetchPost}
handleOnEditPress={handleOnEditPress} handleOnEditPress={handleOnEditPress}
handleOnReplyPress={handleOnReplyPress}
handleOnUserPress={handleOnUserPress} handleOnUserPress={handleOnUserPress}
isLoggedIn={isLoggedIn} isLoggedIn={isLoggedIn}
showComentsToggle={this._showComentsToggle} isShowMoreButton={commentNumber === 1 && item.children > 0}
isShowSubComments={isShowSubComments}
key={item.permlink}
marginLeft={marginLeft}
/> />
</View>
)} )}
/> />
); );

View File

@ -3,6 +3,5 @@ import EStyleSheet from 'react-native-extended-stylesheet';
export default EStyleSheet.create({ export default EStyleSheet.create({
commentWrapper: { commentWrapper: {
padding: 16, padding: 16,
paddingBottom: 50,
}, },
}); });

View File

@ -1,9 +1,11 @@
import React, { PureComponent, Fragment } from 'react'; import React, { PureComponent, Fragment } from 'react';
import { View } from 'react-native'; import { View } from 'react-native';
import { injectIntl } from 'react-intl';
// Components // Components
import { FilterBar } from '../../filterBar'; import { FilterBar } from '../../filterBar';
import { Comments } from '../../comments'; import { Comments } from '../../comments';
import COMMENT_FILTER from '../../../constants/options/comment';
// Styles // Styles
import styles from './commentDisplayStyles'; import styles from './commentDisplayStyles';
@ -16,31 +18,39 @@ class CommentsDisplayView extends PureComponent {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = {}; this.state = {
selectedFilter: null,
};
} }
// Component Life Cycles // Component Life Cycles
// Component Functions // Component Functions
_handleOnDropdownSelect = () => {}; _handleOnDropdownSelect = (index, option) => {
this.setState({ selectedFilter: option });
};
render() { render() {
const { const {
author, permlink, commentCount, fetchPost, author, commentCount, fetchPost, intl, permlink,
} = this.props; } = this.props;
// TODO: implement comments filtering const { selectedFilter } = this.state;
return ( return (
<Fragment> <Fragment>
{commentCount > 0 && ( {commentCount > 0 && (
<Fragment> <Fragment>
<FilterBar <FilterBar
dropdownIconName="arrow-drop-down" dropdownIconName="arrow-drop-down"
options={['TRENDING']} options={COMMENT_FILTER.map(item => intl.formatMessage({ id: `comment_filter.${item}` }).toUpperCase())}
defaultText="TRENDING" defaultText={intl
.formatMessage({ id: `comment_filter.${COMMENT_FILTER[0]}` })
.toUpperCase()}
onDropdownSelect={this._handleOnDropdownSelect} onDropdownSelect={this._handleOnDropdownSelect}
/> />
<View style={styles.commentWrapper}> <View style={styles.commentWrapper}>
<Comments <Comments
selectedFilter={selectedFilter}
fetchPost={fetchPost} fetchPost={fetchPost}
commentCount={commentCount} commentCount={commentCount}
author={author} author={author}
@ -54,4 +64,4 @@ class CommentsDisplayView extends PureComponent {
} }
} }
export default CommentsDisplayView; export default injectIntl(CommentsDisplayView);

View File

@ -1,9 +1,10 @@
import React, { PureComponent } from 'react'; import React, { PureComponent } from 'react';
import { withNavigation } from 'react-navigation';
// Services and Actions // Services and Actions
import { getLeaderboard } from '../../../providers/esteem/esteem'; import { getLeaderboard } from '../../../providers/esteem/esteem';
// Utilities // Constants
import ROUTES from '../../../constants/routeNames';
// Component // Component
import LeaderboardView from '../view/leaderboardView'; import LeaderboardView from '../view/leaderboardView';
@ -19,21 +20,46 @@ class LeaderboardContainer extends PureComponent {
super(props); super(props);
this.state = { this.state = {
users: null, users: null,
refreshing: false,
}; };
} }
// Component Life Cycle Functions // Component Life Cycle Functions
async componentDidMount() { componentDidMount() {
const users = await getLeaderboard(); this._fetchLeaderBoard();
this.setState({ users });
} }
render() { _handleOnUserPress = (username) => {
const { users } = this.state; const { navigation } = this.props;
return <LeaderboardView users={users} handleOnUserPress={this._handleOnUserPress} />; navigation.navigate({
routeName: ROUTES.SCREENS.PROFILE,
params: {
username,
},
});
};
_fetchLeaderBoard = async () => {
this.setState({ refreshing: true });
const users = await getLeaderboard();
this.setState({ users, refreshing: false });
};
render() {
const { users, refreshing } = this.state;
return (
<LeaderboardView
users={users}
refreshing={refreshing}
fetchLeaderBoard={this._fetchLeaderBoard}
handleOnUserPress={this._handleOnUserPress}
/>
);
} }
} }
export default LeaderboardContainer; export default withNavigation(LeaderboardContainer);

View File

@ -2,8 +2,6 @@ import React, { PureComponent } from 'react';
import { View, FlatList, Text } from 'react-native'; import { View, FlatList, Text } from 'react-native';
import { injectIntl } from 'react-intl'; import { injectIntl } from 'react-intl';
// Constants
// Components // Components
import { UserListItem } from '../../basicUIElements'; import { UserListItem } from '../../basicUIElements';
@ -17,20 +15,28 @@ class LeaderboardView extends PureComponent {
*/ */
// Component Functions // Component Functions
_renderItem = (item, index) => ( _renderItem = (item, index) => {
const { handleOnUserPress } = this.props;
return (
<UserListItem <UserListItem
index={index} index={index}
username={item._id} username={item._id}
description={item.created} description={item.created}
isHasRightItem isHasRightItem
isClickable
isBlackRightColor isBlackRightColor
rightText={item.count} rightText={item.count}
itemIndex={index + 1} itemIndex={index + 1}
handleOnPress={() => handleOnUserPress(item._id)}
/> />
); );
};
render() { render() {
const { users, intl } = this.props; const {
users, intl, fetchLeaderBoard, refreshing,
} = this.props;
return ( return (
<View style={styles.container}> <View style={styles.container}>
@ -41,8 +47,10 @@ class LeaderboardView extends PureComponent {
</Text> </Text>
<FlatList <FlatList
data={users} data={users}
refreshing={refreshing}
keyExtractor={item => item.voter} keyExtractor={item => item.voter}
removeClippedSubviews={false} removeClippedSubviews={false}
onRefresh={() => fetchLeaderBoard()}
renderItem={({ item, index }) => this._renderItem(item, index)} renderItem={({ item, index }) => this._renderItem(item, index)}
/> />
</View> </View>

View File

@ -30,11 +30,18 @@ export default ({
} }
} else { } else {
newText = replaceBetween(text, selection, `${imagePrefix}[${itemText}](${itemUrl})`); newText = replaceBetween(text, selection, `${imagePrefix}[${itemText}](${itemUrl})`);
if (isImage) {
newSelection = {
start: newText && newText.length,
end: newText && newText.length,
};
} else {
newSelection = { newSelection = {
start: selection.start + 1, start: selection.start + 1,
end: selection.start + 1 + itemText && itemText.length, end: selection.start + 1 + (itemText && itemText.length),
}; };
} }
}
setState({ text: newText }, () => { setState({ text: newText }, () => {
setState({ newSelection }); setState({ newSelection });
}); });

View File

@ -32,7 +32,7 @@ class PostBody extends PureComponent {
// Component Functions // Component Functions
_handleOnLinkPress = (evt, href, hrefatr) => { _handleOnLinkPress = (evt, href, hrefatr) => {
const { handleOnUserPress, handleOnPostPress, intl } = this.props; const { handleOnUserPress, handleOnPostPress } = this.props;
if (hrefatr.class === 'markdown-author-link') { if (hrefatr.class === 'markdown-author-link') {
if (!handleOnUserPress) { if (!handleOnUserPress) {
@ -47,9 +47,38 @@ class PostBody extends PureComponent {
handleOnPostPress(href); handleOnPostPress(href);
} }
} else { } else {
Linking.canOpenURL(href).then((supported) => { this._handleBrowserLink(href);
}
};
_handleBrowserLink = async (url) => {
if (!url) return;
let author;
let permlink;
const { intl } = this.props;
if (
url.indexOf('esteem') > -1
|| url.indexOf('steemit') > -1
|| url.indexOf('busy') > -1
|| url.indexOf('steempeak') > -1
) {
url = url.substring(url.indexOf('@'), url.length);
const routeParams = url.indexOf('/') > -1 ? url.split('/') : [url];
[, permlink] = routeParams;
author = routeParams[0].indexOf('@') > -1 ? routeParams[0].replace('@', '') : routeParams[0];
}
if (author && permlink) {
this._handleOnPostPress(permlink, author);
} else if (author) {
this._handleOnUserPress(author);
} else {
Linking.canOpenURL(url).then((supported) => {
if (supported) { if (supported) {
Linking.openURL(href); Linking.openURL(url);
} else { } else {
Alert.alert(intl.formatMessage({ id: 'alert.failed_to_open' })); Alert.alert(intl.formatMessage({ id: 'alert.failed_to_open' }));
} }

View File

@ -20,6 +20,7 @@ export default EStyleSheet.create({
scroll: { scroll: {
height: '$deviceHeight / 1.135', height: '$deviceHeight / 1.135',
backgroundColor: '$primaryBackgroundColor', backgroundColor: '$primaryBackgroundColor',
marginBottom: 50,
}, },
footer: { footer: {
flexDirection: 'column', flexDirection: 'column',

View File

@ -115,7 +115,7 @@ class PostDisplayView extends PureComponent {
const { post, fetchPost, parentPost } = this.props; const { post, fetchPost, parentPost } = this.props;
const { postHeight, scrollHeight, isLoadedComments } = this.state; const { postHeight, scrollHeight, isLoadedComments } = this.state;
const isPostEnd = scrollHeight > postHeight; // const isPostEnd = scrollHeight > postHeight;
const isGetComment = scrollHeight + 300 > postHeight; const isGetComment = scrollHeight + 300 > postHeight;
const formatedTime = post && getTimeFromNow(post.created); const formatedTime = post && getTimeFromNow(post.created);
@ -140,7 +140,7 @@ class PostDisplayView extends PureComponent {
size={16} size={16}
/> />
<PostBody body={post.body} /> <PostBody body={post.body} />
<View style={[styles.footer, !isPostEnd && styles.marginFooter]}> <View style={styles.footer}>
<Tags tags={post.json_metadata && post.json_metadata.tags} /> <Tags tags={post.json_metadata && post.json_metadata.tags} />
<Text style={styles.footerText}> <Text style={styles.footerText}>
Posted by Posted by

View File

@ -34,6 +34,7 @@ class SearchModalContainer extends PureComponent {
// Component Functions // Component Functions
_handleCloseButton = () => { _handleCloseButton = () => {
const { navigation } = this.props; const { navigation } = this.props;
navigation.goBack(); navigation.goBack();
}; };

View File

@ -3,9 +3,9 @@
"curation_reward": "কিউরেটর পুরস্কার", "curation_reward": "কিউরেটর পুরস্কার",
"author_reward": "Whats up everyone", "author_reward": "Whats up everyone",
"comment_benefactor_reward": "মন্তব্য উপকারিতার পুরস্কার", "comment_benefactor_reward": "মন্তব্য উপকারিতার পুরস্কার",
"claim_reward_balance": "Claim Reward Balance", "claim_reward_balance": "এখানে iOS ডিভাইসগুলির জন্য eSteem Mobile 2 সাম্প্রতিক আপডেট। নতুন মোবাইল ক্লায়েন্ট পুনঃপ্রতিষ্ঠিত ইউজার ইন্টারফেসের সাথে Steem Blockchain এর জন্য।\n\n>এই সংস্করণটি eSteem 1.6.0 থেকে আলাদা, আপনি আগে এটি ব্যবহার করতে পারেন। এটি নিজে নিজে আপডেট হবে না। এখানে নতুন সংস্করণ ডাউনলোড করুন: [iOS](https:\/\/itunes.apple.com\/WebObjects\/MZStore.woa\/wa\/viewSoftware?id=1451896376&mt=8), [Android](https:\/\/play.google.com\/store\/apps\/details?id=app.esteem.mobile)\n\n**2.0.8 তে কি কি নতুন**\n\nআমাদের Android ব্যবহারকারীদের জন্য সমস্ত কার্যকারিতা আছে। আপনি কিছু সমস্যা খুঁজে পেলে আমাদের রিপোর্ট করুন, যাতে আমরা এটি আরো উন্নত করতে পারি। এখন থেকে আমাদের Android এবং iOS রিলিজগুলো সমস্ত ব্যবহারকারীদের সন্তুষ্ট করতে সক্ষম হবে।\n\nকিছু বৈশিষ্ট্য:\n\n* পোস্ট করতে, কমেন্ট করতে, ভোট দিতে পারবেন\n* বিজ্ঞপ্তি দেওয়া হবে, কার্যক্রম উন্নত\n* একাধিক অ্যাকাউন্ট সমর্থন করা হবে\n* Steemconnect এর মাধ্যমে এবং ঐতিহ্যবাহী লগইন করতে পারবেন\n* কন্টেন্ট খসড়া, বুকমার্ক, পছন্দের তালিকায় রাখতে পারবেন\n* সুন্দর এবং সহজ সম্পাদক, ছবি আপলোড, ক্যাপচার সমর্থন করা হবে\n* সার্ভার নির্বাচন \/ পরিবর্তন করা যাবে\n* রিওয়ার্ড নির্বাচন \/ পরিবর্তন করা যাবে\n* গাঢ় থিম রয়েছে\n* ইংরেজির পাশাপাশি আরও ৫টি ভাষায় কথা বলার ব্যবস্থা রয়েছে\n* পিন কোড দ্বারা নিরাপত্তার ব্যবস্থা রয়েছে\n* এবং আরো অনেক কিছু\n\nঅ্যাপল অ্যাপস্টোর থেকে ডাউনলোড করে এটি পরীক্ষা করে দেখুন এবং আপনার কেমন লাগে তা আমাদের জানান ...\n\nAndroid Version খুঁজছেন?\n\n** পরীক্ষকগণ **\nআমরা এখনও বিটা পরীক্ষক খুঁজছি, মন্তব্য বা GitHub এ এখানে বাগ রিপোর্ট করুন। টেস্ট পুরস্কৃত করা হবে।",
"transfer": "Transfer", "transfer": "স্থানান্তর",
"transfer_to_vesting": "Transfer To Vesting", "transfer_to_vesting": "Vesting কাছে হস্তান্তর",
"transfer_from_savings": "Transfer From Savings", "transfer_from_savings": "Transfer From Savings",
"withdraw_vesting": "Power Down", "withdraw_vesting": "Power Down",
"fill_order": "Fill Order" "fill_order": "Fill Order"

View File

@ -199,5 +199,11 @@
"deep_link": { "deep_link": {
"no_existing_user": "No existing user", "no_existing_user": "No existing user",
"no_existing_post": "No existing post" "no_existing_post": "No existing post"
},
"comment_filter": {
"trending": "trending",
"reputation": "reputation",
"votes": "votes",
"age": "age"
} }
} }

View File

@ -46,8 +46,8 @@
"hours": "시간", "hours": "시간",
"voting_power": "보팅 파워", "voting_power": "보팅 파워",
"login_to_see": "로그인해서 확인하기", "login_to_see": "로그인해서 확인하기",
"havent_commented": "댓글을 작성한 적이 아직 없습니다", "havent_commented": "아직 댓글을 작성한 적이 없습니다",
"havent_posted": "게시한 글이 아직 없습니다", "havent_posted": "아직 게시한 글이 없습니다",
"steem_power": "스팀 파워", "steem_power": "스팀 파워",
"next_power_text": "다음 번 파워 다운까지 남은 기간", "next_power_text": "다음 번 파워 다운까지 남은 기간",
"days": "일", "days": "일",
@ -57,7 +57,7 @@
}, },
"settings": { "settings": {
"settings": "설정", "settings": "설정",
"currency": "화폐 표기", "currency": "화폐",
"language": "언어", "language": "언어",
"server": "서버", "server": "서버",
"dark_theme": "어두운 테마", "dark_theme": "어두운 테마",
@ -120,7 +120,7 @@
}, },
"pincode": { "pincode": {
"enter_text": "잠금을 해제하려면 PIN 코드를 입력해주세요", "enter_text": "잠금을 해제하려면 PIN 코드를 입력해주세요",
"set_new": "새로운 PIN 코드 설정", "set_new": "새로운 PIN 코드 설정하기",
"write_again": "다시 한 번 입력해주세요", "write_again": "다시 한 번 입력해주세요",
"forgot_text": "PIN 코드가 기억나지 않습니다..." "forgot_text": "PIN 코드가 기억나지 않습니다..."
}, },
@ -137,7 +137,7 @@
"warning": "경고", "warning": "경고",
"invalid_pincode": "올바르지 않은 PIN 코드입니다. 확인 후 다시 시도해주세요.", "invalid_pincode": "올바르지 않은 PIN 코드입니다. 확인 후 다시 시도해주세요.",
"remove_alert": "정말 삭제하시겠습니까?", "remove_alert": "정말 삭제하시겠습니까?",
"clear_alert": "정말 삭제하시겠습니까?", "clear_alert": "정말 삭제하시겠습니까?",
"clear": "삭제", "clear": "삭제",
"cancel": "취소", "cancel": "취소",
"delete": "삭제", "delete": "삭제",
@ -145,7 +145,7 @@
"no_internet": "인터넷 연결을 확인하세요!" "no_internet": "인터넷 연결을 확인하세요!"
}, },
"post": { "post": {
"reblog_alert": "정말 리블로그 하시겠습니까?" "reblog_alert": "정말 리블로그 하시겠습니까?"
}, },
"drafts": { "drafts": {
"title": "임시 보관함", "title": "임시 보관함",

View File

@ -0,0 +1 @@
export default ['trending', 'reputation', 'votes', 'age'];

View File

@ -75,10 +75,12 @@ class ApplicationContainer extends Component {
this.state = { this.state = {
isRenderRequire: true, isRenderRequire: true,
isReady: false, isReady: false,
isIos: Platform.OS !== 'android',
}; };
} }
componentDidMount = async () => { componentDidMount = async () => {
const { isIos } = this.state;
let isConnected; let isConnected;
await NetInfo.isConnected.fetch().then((_isConnected) => { await NetInfo.isConnected.fetch().then((_isConnected) => {
@ -86,7 +88,7 @@ class ApplicationContainer extends Component {
}); });
NetInfo.isConnected.addEventListener('connectionChange', this._handleConntectionChange); NetInfo.isConnected.addEventListener('connectionChange', this._handleConntectionChange);
BackHandler.addEventListener('hardwareBackPress', this._onBackPress); if (!isIos) BackHandler.addEventListener('hardwareBackPress', this._onBackPress);
if (isConnected) { if (isConnected) {
this._fetchApp(); this._fetchApp();
@ -116,7 +118,10 @@ class ApplicationContainer extends Component {
} }
componentWillUnmount() { componentWillUnmount() {
BackHandler.removeEventListener('hardwareBackPress', this.onBackPress); const { isIos } = this.state;
if (!isIos) BackHandler.removeEventListener('hardwareBackPress', this._onBackPress);
NetInfo.isConnected.removeEventListener('connectionChange', this._handleConntectionChange); NetInfo.isConnected.removeEventListener('connectionChange', this._handleConntectionChange);
clearInterval(this.globalInterval); clearInterval(this.globalInterval);
} }

View File

@ -71,7 +71,7 @@ class NotificationContainer extends Component {
params: { params: {
author: data.author, author: data.author,
permlink: data.permlink, permlink: data.permlink,
isNotification: true, isHasParentPost: data.parent_author && data.parent_permlink,
}, },
key: data.permlink, key: data.permlink,
}); });

View File

@ -20,7 +20,7 @@ class PostContainer extends Component {
post: null, post: null,
error: null, error: null,
isNewPost: false, isNewPost: false,
isNotification: false, isHasParentPost: false,
parentPost: null, parentPost: null,
}; };
} }
@ -29,7 +29,7 @@ class PostContainer extends Component {
componentDidMount() { componentDidMount() {
const { navigation } = this.props; const { navigation } = this.props;
const { const {
content, permlink, author, isNewPost, isNotification, content, permlink, author, isNewPost, isHasParentPost,
} = navigation.state && navigation.state.params; } = navigation.state && navigation.state.params;
if (isNewPost) this.setState({ isNewPost }); if (isNewPost) this.setState({ isNewPost });
@ -39,7 +39,7 @@ class PostContainer extends Component {
} else if (author && permlink) { } else if (author && permlink) {
this._loadPost(author, permlink); this._loadPost(author, permlink);
if (isNotification) this.setState({ isNotification }); if (isHasParentPost) this.setState({ isHasParentPost });
} }
} }
@ -81,10 +81,10 @@ class PostContainer extends Component {
render() { render() {
const { currentAccount, isLoggedIn } = this.props; const { currentAccount, isLoggedIn } = this.props;
const { const {
error, isNewPost, parentPost, post, isNotification, error, isNewPost, parentPost, post, isHasParentPost,
} = this.state; } = this.state;
if (isNotification && post) this._loadPost(post.parent_author, post.parent_permlink, true); if (isHasParentPost && post) this._loadPost(post.parent_author, post.parent_permlink, true);
return ( return (
<PostScreen <PostScreen

View File

@ -0,0 +1,24 @@
export default (input) => {
if (input === 0) {
return 25;
}
if (!input) {
return input;
}
let neg = false;
if (input < 0) neg = true;
let reputationLevel = Math.log10(Math.abs(input));
reputationLevel = Math.max(reputationLevel - 9, 0);
if (reputationLevel < 0) reputationLevel = 0;
if (neg) reputationLevel *= -1;
reputationLevel = reputationLevel * 9 + 25;
return Math.floor(reputationLevel);
};

View File

@ -56,6 +56,7 @@ export const parsePost = (post, currentUserName, isSummary = false) => {
const isVoted = (activeVotes, currentUserName) => activeVotes.some(v => v.voter === currentUserName && v.percent > 0); const isVoted = (activeVotes, currentUserName) => activeVotes.some(v => v.voter === currentUserName && v.percent > 0);
const postImage = (metaData, body) => { const postImage = (metaData, body) => {
const imgTagRegex = /(<img[^>]*>)/g;
const markdownImageRegex = /!\[[^\]]*\]\((.*?)\s*("(?:.*[^"])")?\s*\)/g; const markdownImageRegex = /!\[[^\]]*\]\((.*?)\s*("(?:.*[^"])")?\s*\)/g;
const urlRegex = /(http|ftp|https):\/\/([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?/gm; const urlRegex = /(http|ftp|https):\/\/([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?/gm;
const imageRegex = /(http(s?):)([/|.|\w|\s|-])*\.(?:jpg|gif|png)/g; const imageRegex = /(http(s?):)([/|.|\w|\s|-])*\.(?:jpg|gif|png)/g;
@ -76,47 +77,56 @@ const postImage = (metaData, body) => {
imageLink = imageMatch[0]; imageLink = imageMatch[0];
} }
if (!imageLink && imgTagRegex.test(body)) {
const _imgTag = body.match(imgTagRegex);
const match = _imgTag[0].match(urlRegex);
if (match && match[0]) {
imageLink = match[0];
}
}
if (imageLink) { if (imageLink) {
return `https://steemitimages.com/600x0/${imageLink}`; return `https://steemitimages.com/600x0/${imageLink}`;
} }
return ''; return '';
}; };
export const protocolUrl2Obj = (url) => { // export const protocolUrl2Obj = (url) => {
let urlPart = url.split('://')[1]; // let urlPart = url.split('://')[1];
// remove last char if / // // remove last char if /
if (urlPart.endsWith('/')) { // if (urlPart.endsWith('/')) {
urlPart = urlPart.substring(0, urlPart.length - 1); // urlPart = urlPart.substring(0, urlPart.length - 1);
} // }
const parts = urlPart.split('/'); // const parts = urlPart.split('/');
// filter // // filter
if (parts.length === 1) { // if (parts.length === 1) {
return { type: 'filter' }; // return { type: 'filter' };
} // }
// filter with tag // // filter with tag
if (parts.length === 2) { // if (parts.length === 2) {
return { type: 'filter-tag', filter: parts[0], tag: parts[1] }; // return { type: 'filter-tag', filter: parts[0], tag: parts[1] };
} // }
// account // // account
if (parts.length === 1 && parts[0].startsWith('@')) { // if (parts.length === 1 && parts[0].startsWith('@')) {
return { type: 'account', account: parts[0].replace('@', '') }; // return { type: 'account', account: parts[0].replace('@', '') };
} // }
// post // // post
if (parts.length === 3 && parts[1].startsWith('@')) { // if (parts.length === 3 && parts[1].startsWith('@')) {
return { // return {
type: 'post', // type: 'post',
cat: parts[0], // cat: parts[0],
author: parts[1].replace('@', ''), // author: parts[1].replace('@', ''),
permlink: parts[2], // permlink: parts[2],
}; // };
} // }
}; // };
export const parseComments = (comments) => { export const parseComments = (comments) => {
comments.map((comment) => { comments.map((comment) => {