ran lint:fix

This commit is contained in:
feruz 2019-11-29 20:13:50 +02:00
parent c05c5ebb2a
commit f248f6add0
48 changed files with 352 additions and 186 deletions

View File

@ -46,7 +46,9 @@ class BasicHeaderView extends Component {
this.setState({ isInputVisible: !isInputVisible }); this.setState({ isInputVisible: !isInputVisible });
if (isInputVisible) this._handleOnSearch(''); if (isInputVisible) {
this._handleOnSearch('');
}
}; };
_handleOnSearch = value => { _handleOnSearch = value => {

View File

@ -22,7 +22,7 @@ export default EStyleSheet.create({
borderRadius: 50, borderRadius: 50,
}, },
isFilter: { isFilter: {
backgroundColor: 'transparent' backgroundColor: 'transparent',
}, },
isFilterTextUnPin: { isFilterTextUnPin: {
color: '$primaryDarkGray', color: '$primaryDarkGray',

View File

@ -5,9 +5,22 @@ import styles from './tagStyles';
const Tag = ({ onPress, isPin, value, isPostCardTag, isFilter }) => ( const Tag = ({ onPress, isPin, value, isPostCardTag, isFilter }) => (
<TouchableOpacity onPress={() => onPress && onPress(value)}> <TouchableOpacity onPress={() => onPress && onPress(value)}>
<View <View
style={[styles.textWrapper, isFilter && styles.isFilter, isPin && styles.isPin, isPostCardTag && styles.isPostCardTag]} style={[
styles.textWrapper,
isFilter && styles.isFilter,
isPin && styles.isPin,
isPostCardTag && styles.isPostCardTag,
]}
> >
<Text style={[styles.text, !isPin && isFilter && styles.isFilterTextUnPin, isPin && isFilter && styles.isFilterTextPin]}>{value}</Text> <Text
style={[
styles.text,
!isPin && isFilter && styles.isFilterTextUnPin,
isPin && isFilter && styles.isFilterTextPin,
]}
>
{value}
</Text>
</View> </View>
</TouchableOpacity> </TouchableOpacity>
); );

View File

@ -51,7 +51,9 @@ class CollapsibleCardView extends PureComponent {
// Component Functions // Component Functions
_initContentHeight = event => { _initContentHeight = event => {
if (this.anime.contentHeight > 0) return; if (this.anime.contentHeight > 0) {
return;
}
this.anime.contentHeight = event.nativeEvent.layout.height; this.anime.contentHeight = event.nativeEvent.layout.height;
this.anime.height.setValue(this.anime.expanded ? this._getMaxValue() : this._getMinValue()); this.anime.height.setValue(this.anime.expanded ? this._getMaxValue() : this._getMinValue());
}; };
@ -72,7 +74,9 @@ class CollapsibleCardView extends PureComponent {
expanded: this.anime.expanded, expanded: this.anime.expanded,
}); });
if (handleOnExpanded && this.anime.expanded) handleOnExpanded(); if (handleOnExpanded && this.anime.expanded) {
handleOnExpanded();
}
}; };
render() { render() {

View File

@ -85,8 +85,12 @@ class CommentsContainer extends Component {
const keyA = get(a, 'author_reputation'); const keyA = get(a, 'author_reputation');
const keyB = get(b, 'author_reputation'); const keyB = get(b, 'author_reputation');
if (keyA > keyB) return -1; if (keyA > keyB) {
if (keyA < keyB) return 1; return -1;
}
if (keyA < keyB) {
return 1;
}
return 0; return 0;
}, },
@ -94,8 +98,12 @@ class CommentsContainer extends Component {
const keyA = a.net_votes; const keyA = a.net_votes;
const keyB = b.net_votes; const keyB = b.net_votes;
if (keyA > keyB) return -1; if (keyA > keyB) {
if (keyA < keyB) return 1; return -1;
}
if (keyA < keyB) {
return 1;
}
return 0; return 0;
}, },
@ -111,8 +119,12 @@ class CommentsContainer extends Component {
const keyA = Date.parse(get(a, 'created')); const keyA = Date.parse(get(a, 'created'));
const keyB = Date.parse(get(b, 'created')); const keyB = Date.parse(get(b, 'created'));
if (keyA > keyB) return -1; if (keyA > keyB) {
if (keyA < keyB) return 1; return -1;
}
if (keyA < keyB) {
return 1;
}
return 0; return 0;
}, },
@ -149,7 +161,7 @@ class CommentsContainer extends Component {
}); });
} }
}) })
.catch(() => { }); .catch(() => {});
} }
}; };

View File

@ -50,7 +50,9 @@ class CommentsDisplayView extends PureComponent {
dropdownIconName="arrow-drop-down" dropdownIconName="arrow-drop-down"
options={VALUE.map(val => intl.formatMessage({ id: `comment_filter.${val}` }))} options={VALUE.map(val => intl.formatMessage({ id: `comment_filter.${val}` }))}
defaultText={intl.formatMessage({ id: `comment_filter.${VALUE[0]}` })} defaultText={intl.formatMessage({ id: `comment_filter.${VALUE[0]}` })}
onDropdownSelect={selectedIndex => this._handleOnDropdownSelect(COMMENT_FILTER[selectedIndex], selectedIndex)} onDropdownSelect={selectedIndex =>
this._handleOnDropdownSelect(COMMENT_FILTER[selectedIndex], selectedIndex)
}
selectedOptionIndex={selectedOptionIndex} selectedOptionIndex={selectedOptionIndex}
/> />
<View style={styles.commentWrapper}> <View style={styles.commentWrapper}>

View File

@ -16,7 +16,7 @@ export default EStyleSheet.create({
flexDirection: 'row', flexDirection: 'row',
justifyContent: 'center', justifyContent: 'center',
alignItems: 'center', alignItems: 'center',
left: 15 left: 15,
}, },
filterBarWrapper: { filterBarWrapper: {
flexDirection: 'row', flexDirection: 'row',
@ -30,5 +30,5 @@ export default EStyleSheet.create({
rightIcon: { rightIcon: {
color: '$darkIconColor', color: '$darkIconColor',
textAlign: 'center', textAlign: 'center',
} },
}); });

View File

@ -28,30 +28,37 @@ const FilterBarView = ({
rightIconType, rightIconType,
selectedOptionIndex, selectedOptionIndex,
}) => ( }) => (
<View style={styles.container}> <View style={styles.container}>
{!isHide && ( {!isHide && (
<LineBreak height={38}> <LineBreak height={38}>
<View style={styles.filterBarWrapper}> <View style={styles.filterBarWrapper}>
<View style={styles.dropdownWrapper}> <View style={styles.dropdownWrapper}>
{options.map((item, index) => <Tag value={item} isFilter isPin={index == selectedOptionIndex} onPress={() => onDropdownSelect(index)} />)} {options.map((item, index) => (
</View> <Tag
{rightIconName && ( value={item}
<TouchableOpacity isFilter
onPress={() => onRightIconPress && onRightIconPress()} isPin={index == selectedOptionIndex}
style={styles.rightIconWrapper} onPress={() => onDropdownSelect(index)}
> />
<Icon ))}
style={styles.rightIcon}
size={iconSize || 28}
iconType={rightIconType}
name={rightIconName}
/>
</TouchableOpacity>
)}
</View> </View>
</LineBreak> {rightIconName && (
)} <TouchableOpacity
</View> onPress={() => onRightIconPress && onRightIconPress()}
); style={styles.rightIconWrapper}
>
<Icon
style={styles.rightIcon}
size={iconSize || 28}
iconType={rightIconType}
name={rightIconName}
/>
</TouchableOpacity>
)}
</View>
</LineBreak>
)}
</View>
);
export default FilterBarView; export default FilterBarView;

View File

@ -47,7 +47,9 @@ class FormInputView extends Component {
const { onChange } = this.props; const { onChange } = this.props;
this.setState({ value }); this.setState({ value });
if (onChange) onChange(value); if (onChange) {
onChange(value);
}
}; };
_handleOnFocus = () => { _handleOnFocus = () => {

View File

@ -82,7 +82,9 @@ class IconView extends PureComponent {
_badgeCount = '99+'; _badgeCount = '99+';
} }
if (!badgeCount) return this._getIcon(); if (!badgeCount) {
return this._getIcon();
}
return this._getIconWithBadge(_badgeCount); return this._getIconWithBadge(_badgeCount);
} }

View File

@ -59,7 +59,9 @@ class LeaderboardContainer extends PureComponent {
let users; let users;
console.log(index); console.log(index);
if (!isConnected) return; if (!isConnected) {
return;
}
this.setState({ refreshing: true, selectedIndex: index }); this.setState({ refreshing: true, selectedIndex: index });

View File

@ -47,7 +47,9 @@ class LeaderboardView extends PureComponent {
options={VALUE.map(val => intl.formatMessage({ id: `leaderboard.${val}` }))} options={VALUE.map(val => intl.formatMessage({ id: `leaderboard.${val}` }))}
selectedOptionIndex={selectedIndex} selectedOptionIndex={selectedIndex}
defaultText={intl.formatMessage({ id: `leaderboard.${VALUE[0]}` })} defaultText={intl.formatMessage({ id: `leaderboard.${VALUE[0]}` })}
onDropdownSelect={selectedIndex => fetchLeaderBoard(FILTER_OPTIONS[selectedIndex], selectedIndex)} onDropdownSelect={selectedIndex =>
fetchLeaderBoard(FILTER_OPTIONS[selectedIndex], selectedIndex)
}
/> />
<View style={styles.container}> <View style={styles.container}>

View File

@ -45,13 +45,13 @@ const MarkdownEditorView = ({
if (!isPreviewActive) { if (!isPreviewActive) {
_setTextAndSelection({ selection: { start: 0, end: 0 }, text }); _setTextAndSelection({ selection: { start: 0, end: 0 }, text });
} }
}, [isPreviewActive]); }, [_setTextAndSelection, isPreviewActive, text]);
useEffect(() => { useEffect(() => {
if (text === '' && draftBody !== '') { if (text === '' && draftBody !== '') {
_setTextAndSelection({ selection: { start: 0, end: 0 }, text: draftBody }); _setTextAndSelection({ selection: { start: 0, end: 0 }, text: draftBody });
} }
}, [draftBody]); }, [_setTextAndSelection, draftBody, text]);
useEffect(() => { useEffect(() => {
if (editable === null) { if (editable === null) {
@ -63,7 +63,7 @@ const MarkdownEditorView = ({
} else { } else {
setEditable(!isLoading); setEditable(!isLoading);
} }
}, [isLoading]); }, [editable, isLoading]);
useEffect(() => { useEffect(() => {
if (uploadedImage && uploadedImage.url) { if (uploadedImage && uploadedImage.url) {
@ -75,7 +75,7 @@ const MarkdownEditorView = ({
isImage: !!uploadedImage, isImage: !!uploadedImage,
}); });
} }
}, [uploadedImage]); }, [_setTextAndSelection, selection, text, uploadedImage]);
useEffect(() => { useEffect(() => {
setText(draftBody); setText(draftBody);
@ -91,9 +91,9 @@ const MarkdownEditorView = ({
handleIsFormValid(text); handleIsFormValid(text);
} }
} }
}, [text]); }, [_changeText, handleIsFormValid, text]);
const _changeText = input => { const _changeText = useCallback(input => {
setText(input); setText(input);
if (onChange) { if (onChange) {
@ -107,13 +107,13 @@ const MarkdownEditorView = ({
if (handleOnTextChange) { if (handleOnTextChange) {
handleOnTextChange(input); handleOnTextChange(input);
} }
}; });
const _handleOnSelectionChange = async event => { const _handleOnSelectionChange = async event => {
setSelection(event.nativeEvent.selection); setSelection(event.nativeEvent.selection);
}; };
const _setTextAndSelection = ({ selection: _selection, text: _text }) => { const _setTextAndSelection = useCallback(({ selection: _selection, text: _text }) => {
inputRef.current.setNativeProps({ inputRef.current.setNativeProps({
text: _text, text: _text,
}); });
@ -125,7 +125,7 @@ const MarkdownEditorView = ({
setSelection(_selection); setSelection(_selection);
}, 200); }, 200);
_changeText(_text); _changeText(_text);
}; });
const _renderPreview = () => ( const _renderPreview = () => (
<ScrollView style={styles.previewContainer}> <ScrollView style={styles.previewContainer}>

View File

@ -85,7 +85,9 @@ class NotificationView extends PureComponent {
_getNotificationsArrays = () => { _getNotificationsArrays = () => {
const { notifications, intl } = this.props; const { notifications, intl } = this.props;
if (!notifications && notifications.length < 1) return null; if (!notifications && notifications.length < 1) {
return null;
}
const notificationArray = [ const notificationArray = [
{ {
@ -130,13 +132,21 @@ class NotificationView extends PureComponent {
}; };
_getTimeListIndex = timestamp => { _getTimeListIndex = timestamp => {
if (isToday(timestamp)) return 0; if (isToday(timestamp)) {
return 0;
}
if (isYesterday(timestamp)) return 1; if (isYesterday(timestamp)) {
return 1;
}
if (isThisWeek(timestamp)) return 2; if (isThisWeek(timestamp)) {
return 2;
}
if (isThisMonth(timestamp)) return 3; if (isThisMonth(timestamp)) {
return 3;
}
return 4; return 4;
}; };

View File

@ -39,7 +39,9 @@ class PercentBarView extends PureComponent {
_getText = (textColor, text, isTop, isRender) => { _getText = (textColor, text, isTop, isRender) => {
const { isShowText } = this.props; const { isShowText } = this.props;
if (!isShowText) return null; if (!isShowText) {
return null;
}
if (isTop === isRender && text) { if (isTop === isRender && text) {
return ( return (

View File

@ -252,7 +252,11 @@ class BoostPostScreen extends PureComponent {
cancelButtonIndex={1} cancelButtonIndex={1}
destructiveButtonIndex={0} destructiveButtonIndex={0}
onPress={index => { onPress={index => {
if (index === 0) if (index === 0) this._handleOnSubmit(); if (index === 0) {
if (index === 0) {
this._handleOnSubmit();
}
}
}} }}
/> />

View File

@ -67,7 +67,7 @@ const PostBody = ({
default: default:
break; break;
} }
} catch (error) { } } catch (error) {}
}; };
const _handleTagPress = tag => { const _handleTagPress = tag => {

View File

@ -91,7 +91,9 @@ class PostListItemView extends Component {
cancelButtonIndex={1} cancelButtonIndex={1}
destructiveButtonIndex={0} destructiveButtonIndex={0}
onPress={index => { onPress={index => {
if (index === 0) handleOnRemoveItem(id); if (index === 0) {
handleOnRemoveItem(id);
}
}} }}
/> />
</Fragment> </Fragment>

View File

@ -114,7 +114,9 @@ class PostDisplayContainer extends Component {
_fetchPost = async () => { _fetchPost = async () => {
const { post, fetchPost } = this.props; const { post, fetchPost } = this.props;
if (post) fetchPost(post.author, post.permlink); if (post) {
fetchPost(post.author, post.permlink);
}
}; };
render() { render() {

View File

@ -140,7 +140,7 @@ const PostsView = ({
setPromotedPosts(_promotedPosts); setPromotedPosts(_promotedPosts);
} }
}) })
.catch(() => { }); .catch(() => {});
}, [currentAccountUsername]); }, [currentAccountUsername]);
const _loadPosts = useCallback( const _loadPosts = useCallback(

View File

@ -46,7 +46,9 @@ class ProfileSummaryView extends PureComponent {
// Component Functions // Component Functions
_handleOnPressLink = url => { _handleOnPressLink = url => {
if (url) Linking.openURL(url); if (url) {
Linking.openURL(url);
}
}; };
_handleOnDropdownSelect = index => { _handleOnDropdownSelect = index => {

View File

@ -230,7 +230,9 @@ class PromoteView extends PureComponent {
cancelButtonIndex={1} cancelButtonIndex={1}
destructiveButtonIndex={0} destructiveButtonIndex={0}
onPress={index => { onPress={index => {
if (index === 0) this._handleOnSubmit(); if (index === 0) {
this._handleOnSubmit();
}
}} }}
/> />
<Modal <Modal

View File

@ -25,7 +25,9 @@ export default class ScaleSliderView extends Component {
activeIndex: index, activeIndex: index,
}); });
if (handleOnValueChange) handleOnValueChange(values[index]); if (handleOnValueChange) {
handleOnValueChange(values[index]);
}
}; };
_renderItem = (value, index, activeIndex) => { _renderItem = (value, index, activeIndex) => {

View File

@ -43,11 +43,15 @@ class SearchModalContainer extends PureComponent {
_handleOnChangeSearchInput = text => { _handleOnChangeSearchInput = text => {
const { isConnected } = this.props; const { isConnected } = this.props;
if (text && text.length < 2) return; if (text && text.length < 2) {
return;
}
if (this.timer) { if (this.timer) {
clearTimeout(this.timer); clearTimeout(this.timer);
} }
if (!isConnected) return; if (!isConnected) {
return;
}
if (text && text !== '@' && text !== '#') { if (text && text !== '@' && text !== '#') {
if (text[0] === '@') { if (text[0] === '@') {
lookupAccounts(text.substr(1)).then(res => { lookupAccounts(text.substr(1)).then(res => {

View File

@ -43,7 +43,9 @@ class ToastNotification extends Component {
const { onHide } = this.props; const { onHide } = this.props;
Animated.timing(animatedValue, { toValue: 0.0, duration: 350 }).start(() => { Animated.timing(animatedValue, { toValue: 0.0, duration: 350 }).start(() => {
if (onHide) onHide(); if (onHide) {
onHide();
}
}); });
if (this.closeTimer) { if (this.closeTimer) {

View File

@ -80,7 +80,9 @@ class ToggleSwitchView extends PureComponent {
// For debounce // For debounce
setTimeout(() => { setTimeout(() => {
if (onToggle) onToggle(!isOn); if (onToggle) {
onToggle(!isOn);
}
}, 300); }, 300);
}; };

View File

@ -60,7 +60,9 @@ class ProfileContainer extends Component {
const { isOwnProfile } = this.state; const { isOwnProfile } = this.state;
let targetUsername = currentAccountUsername; let targetUsername = currentAccountUsername;
if (!isConnected) return; if (!isConnected) {
return;
}
if (!isLoggedIn && !username) { if (!isLoggedIn && !username) {
navigation.navigate(ROUTES.SCREENS.LOGIN); navigation.navigate(ROUTES.SCREENS.LOGIN);
@ -75,7 +77,9 @@ class ProfileContainer extends Component {
} }
UNSAFE_componentWillReceiveProps(nextProps) { UNSAFE_componentWillReceiveProps(nextProps) {
if (!nextProps.isConnected) return; if (!nextProps.isConnected) {
return;
}
const { isLoggedIn, navigation } = this.props; const { isLoggedIn, navigation } = this.props;
const { isOwnProfile } = this.state; const { isOwnProfile } = this.state;

View File

@ -56,7 +56,9 @@ class TransferContainer extends Component {
this.setState({ balance }); this.setState({ balance });
}) })
.catch(err => { .catch(err => {
if (err) alert(get(err, 'message') || err.toString()); if (err) {
alert(get(err, 'message') || err.toString());
}
}); });
}; };

View File

@ -122,7 +122,9 @@ export const getUser = async user => {
const _account = { ...account[0] }; const _account = { ...account[0] };
let unreadActivityCount; let unreadActivityCount;
if (account && account.length < 1) return null; if (account && account.length < 1) {
return null;
}
const globalProperties = await client.database.getDynamicGlobalProperties(); const globalProperties = await client.database.getDynamicGlobalProperties();
const rcPower = await client.call('rc_api', 'find_rc_accounts', { accounts: [user] }); const rcPower = await client.call('rc_api', 'find_rc_accounts', { accounts: [user] });

View File

@ -52,7 +52,9 @@ class FollowsContainer extends Component {
let _startWith; let _startWith;
const { username, users, isFollowingPress, startWith, count } = this.state; const { username, users, isFollowingPress, startWith, count } = this.state;
if ((users && count < 100) || (users && count === users.length + 1)) return; if ((users && count < 100) || (users && count === users.length + 1)) {
return;
}
const name = username || _username; const name = username || _username;
const isFollowing = isFollowingPress || _isFollowingPress; const isFollowing = isFollowingPress || _isFollowingPress;
@ -71,7 +73,9 @@ class FollowsContainer extends Component {
}); });
} }
if (!_username) _users.shift(); if (!_username) {
_users.shift();
}
this.setState({ this.setState({
users: !_username ? [...users, ..._users] : _users, users: !_username ? [...users, ..._users] : _users,

View File

@ -124,7 +124,9 @@ class LoginContainer extends PureComponent {
_getAccountsWithUsername = async username => { _getAccountsWithUsername = async username => {
const { intl, isConnected } = this.props; const { intl, isConnected } = this.props;
if (!isConnected) return null; if (!isConnected) {
return null;
}
try { try {
const validUsers = await lookupAccounts(username); const validUsers = await lookupAccounts(username);

View File

@ -32,7 +32,9 @@ class PostContainer extends Component {
const { navigation } = this.props; const { navigation } = this.props;
const { content, permlink, author, isNewPost } = get(navigation, 'state.params'); const { content, permlink, author, isNewPost } = get(navigation, 'state.params');
if (isNewPost) this.setState({ isNewPost }); if (isNewPost) {
this.setState({ isNewPost });
}
if (content) { if (content) {
this.setState({ post: content }); this.setState({ post: content });

View File

@ -7,54 +7,54 @@ import { SteemWalletContainer, AccountContainer } from '../../../containers';
import globalStyles from '../../../globalStyles'; import globalStyles from '../../../globalStyles';
const SbdView = ({ handleOnSelected, index, currentIndex }) => ( const SbdView = ({ handleOnSelected, index, currentIndex }) => (
<View style={globalStyles.swipeItemWrapper}> <View style={globalStyles.swipeItemWrapper}>
<AccountContainer> <AccountContainer>
{({ currentAccount }) => ( {({ currentAccount }) => (
<SteemWalletContainer selectedUser={currentAccount}> <SteemWalletContainer selectedUser={currentAccount}>
{({ {({
isClaiming, isClaiming,
claimRewardBalance, claimRewardBalance,
handleOnWalletRefresh, handleOnWalletRefresh,
refreshing, refreshing,
transferHistory, transferHistory,
sbdBalance, sbdBalance,
isLoading, isLoading,
sbdSavingBalance, sbdSavingBalance,
estimatedValue, estimatedValue,
sbdDropdown, sbdDropdown,
savingSbdDropdown, savingSbdDropdown,
navigate, navigate,
}) => ( }) => (
<WalletHeader <WalletHeader
componentDidUpdate={() => handleOnSelected(transferHistory, isLoading)} componentDidUpdate={() => handleOnSelected(transferHistory, isLoading)}
index={index} index={index}
claim={claimRewardBalance} claim={claimRewardBalance}
fetchUserActivity={handleOnWalletRefresh} fetchUserActivity={handleOnWalletRefresh}
isClaiming={isClaiming} isClaiming={isClaiming}
isLoading={isLoading} isLoading={isLoading}
refreshing={refreshing} refreshing={refreshing}
unclaimedBalance={0} unclaimedBalance={0}
userBalance={[ userBalance={[
{ balance: sbdBalance, nameKey: 'sbd', options: sbdDropdown }, { balance: sbdBalance, nameKey: 'sbd', options: sbdDropdown },
{ balance: sbdSavingBalance, nameKey: 'savingsbd', options: savingSbdDropdown }, { balance: sbdSavingBalance, nameKey: 'savingsbd', options: savingSbdDropdown },
]} ]}
handleOnDropdownSelected={option => navigate(option, 'SBD')} handleOnDropdownSelected={option => navigate(option, 'SBD')}
type="sbd" type="sbd"
currentIndex={currentIndex} currentIndex={currentIndex}
showIconList={false} showIconList={false}
valueDescriptions={[ valueDescriptions={[
{ {
textKey: 'estimated_value', textKey: 'estimated_value',
value: <FormatedCurrency isApproximate value={estimatedValue} />, value: <FormatedCurrency isApproximate value={estimatedValue} />,
subTextKey: 'estimated_value_desc', subTextKey: 'estimated_value_desc',
}, },
]} ]}
/> />
)} )}
</SteemWalletContainer> </SteemWalletContainer>
)} )}
</AccountContainer> </AccountContainer>
</View> </View>
); );
export default SbdView; export default SbdView;

View File

@ -25,32 +25,36 @@ const SteemView = ({ handleOnSelected, index, currentIndex }) => (
savingSteemDropdown, savingSteemDropdown,
navigate, navigate,
}) => ( }) => (
<WalletHeader <WalletHeader
componentDidUpdate={() => handleOnSelected(transferHistory, isLoading)} componentDidUpdate={() => handleOnSelected(transferHistory, isLoading)}
index={index} index={index}
claim={claimRewardBalance} claim={claimRewardBalance}
fetchUserActivity={handleOnWalletRefresh} fetchUserActivity={handleOnWalletRefresh}
isClaiming={isClaiming} isClaiming={isClaiming}
isLoading={isLoading} isLoading={isLoading}
refreshing={refreshing} refreshing={refreshing}
unclaimedBalance={0} unclaimedBalance={0}
userBalance={[ userBalance={[
{ balance: steemBalance, nameKey: 'steem', options: steemDropdown }, { balance: steemBalance, nameKey: 'steem', options: steemDropdown },
{ balance: steemSavingBalance, nameKey: 'savingsteem', options: savingSteemDropdown }, {
]} balance: steemSavingBalance,
handleOnDropdownSelected={option => navigate(option, 'STEEM')} nameKey: 'savingsteem',
type="steem" options: savingSteemDropdown,
currentIndex={currentIndex} },
showIconList={false} ]}
valueDescriptions={[ handleOnDropdownSelected={option => navigate(option, 'STEEM')}
{ type="steem"
textKey: 'estimated_value', currentIndex={currentIndex}
value: <FormatedCurrency isApproximate value={estimatedValue} />, showIconList={false}
subTextKey: 'estimated_value_desc', valueDescriptions={[
}, {
]} textKey: 'estimated_value',
/> value: <FormatedCurrency isApproximate value={estimatedValue} />,
)} subTextKey: 'estimated_value_desc',
},
]}
/>
)}
</SteemWalletContainer> </SteemWalletContainer>
)} )}
</AccountContainer> </AccountContainer>

View File

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

View File

@ -6,7 +6,9 @@ const readFromClipboard = async () => {
}; };
const writeToClipboard = async text => { const writeToClipboard = async text => {
if (!text) return false; if (!text) {
return false;
}
await Clipboard.setString(text); await Clipboard.setString(text);

View File

@ -1,11 +1,15 @@
export const vestsToSp = (vests, steemPerMVests) => { export const vestsToSp = (vests, steemPerMVests) => {
if (!vests || !steemPerMVests) return 0; if (!vests || !steemPerMVests) {
return 0;
}
return (vests / 1e6) * steemPerMVests; return (vests / 1e6) * steemPerMVests;
}; };
export const vestsToRshares = (vests, votingPower, votePerc) => { export const vestsToRshares = (vests, votingPower, votePerc) => {
if (!vests || !votingPower || !votePerc) return 0; if (!vests || !votingPower || !votePerc) {
return 0;
}
const vestingShares = parseInt(vests * 1e6, 10); const vestingShares = parseInt(vests * 1e6, 10);
const power = (votingPower * votePerc) / 1e4 / 50 + 1; const power = (votingPower * votePerc) / 1e4 / 50 + 1;

View File

@ -8,7 +8,9 @@ export const getWordsCount = text =>
const permlinkRnd = () => (Math.random() + 1).toString(16).substring(2); const permlinkRnd = () => (Math.random() + 1).toString(16).substring(2);
export const generatePermlink = (title, random = false) => { export const generatePermlink = (title, random = false) => {
if (!title) return ''; if (!title) {
return '';
}
const slug = getSlug(title); const slug = getSlug(title);
let perm = slug && slug.toString(); let perm = slug && slug.toString();
@ -36,7 +38,9 @@ export const generatePermlink = (title, random = false) => {
}; };
export const generateReplyPermlink = toAuthor => { export const generateReplyPermlink = toAuthor => {
if (!toAuthor) return ''; if (!toAuthor) {
return '';
}
const t = new Date(Date.now()); const t = new Date(Date.now());
@ -54,7 +58,9 @@ export const generateReplyPermlink = toAuthor => {
}; };
export const makeOptions = (author, permlink, operationType) => { export const makeOptions = (author, permlink, operationType) => {
if (!author || !permlink) return {}; if (!author || !permlink) {
return {};
}
const a = { const a = {
allow_curation_rewards: true, allow_curation_rewards: true,
@ -154,7 +160,9 @@ export const extractMetadata = body => {
}; };
export const createPatch = (text1, text2) => { export const createPatch = (text1, text2) => {
if (!text1 && text1 === '') return undefined; if (!text1 && text1 === '') {
return undefined;
}
const dmp = new diffMatchPatch(); const dmp = new diffMatchPatch();
const patches = dmp.patch_make(text1, text2); const patches = dmp.patch_make(text1, text2);

View File

@ -1,7 +1,13 @@
export const makeCountFriendly = value => { export const makeCountFriendly = value => {
if (!value) return value; if (!value) {
if (value >= 1000000) return `${intlFormat(value / 1000000)}M`; return value;
if (value >= 1000) return `${intlFormat(value / 1000)}K`; }
if (value >= 1000000) {
return `${intlFormat(value / 1000000)}M`;
}
if (value >= 1000) {
return `${intlFormat(value / 1000)}K`;
}
return intlFormat(value); return intlFormat(value);
}; };

View File

@ -38,17 +38,23 @@ export const catchEntryImage = (entry, width = 0, height = 0) => {
// try to extract images by regex // try to extract images by regex
const imgReg2 = /(http(s?):)([/|.|\w|\s|-])*\.(?:jpe?g|gif|png)/gim; const imgReg2 = /(http(s?):)([/|.|\w|\s|-])*\.(?:jpe?g|gif|png)/gim;
const m = entry.body.match(imgReg2); const m = entry.body.match(imgReg2);
if (m) return proxifyImageSrc(m[0], width, height); if (m) {
return proxifyImageSrc(m[0], width, height);
}
// If no image specified in json metadata, try extract first image href from entry body // If no image specified in json metadata, try extract first image href from entry body
let imgReg = /<img.+src=(?:"|')(.+?)(?:"|')(.*)>/; let imgReg = /<img.+src=(?:"|')(.+?)(?:"|')(.*)>/;
let bodyMatch = entry.body.match(imgReg); let bodyMatch = entry.body.match(imgReg);
if (bodyMatch) return proxifyImageSrc(bodyMatch[1], width, height); if (bodyMatch) {
return proxifyImageSrc(bodyMatch[1], width, height);
}
// If there is no <img> tag, check from markdown img tag ![](image.png) // If there is no <img> tag, check from markdown img tag ![](image.png)
imgReg = /(?:!\[(.*?)\]\((.*?)\))/; imgReg = /(?:!\[(.*?)\]\((.*?)\))/;
bodyMatch = imgReg.exec(entry.body); bodyMatch = imgReg.exec(entry.body);
if (bodyMatch) return proxifyImageSrc(bodyMatch[2], width, height); if (bodyMatch) {
return proxifyImageSrc(bodyMatch[2], width, height);
}
return null; return null;
}; };
@ -65,15 +71,21 @@ export const catchDraftImage = body => {
}; };
export const getResizedImage = (url, size = 400) => { export const getResizedImage = (url, size = 400) => {
if (!url) return ''; if (!url) {
return '';
}
if (url.includes('img.esteem')) return `https://img.esteem.ws/${size}x0/${url}`; if (url.includes('img.esteem')) {
return `https://img.esteem.ws/${size}x0/${url}`;
}
return `https://steemitimages.com/${size}x0/${url}`; return `https://steemitimages.com/${size}x0/${url}`;
}; };
export const getResizedAvatar = (author, sizeString = 'small') => { export const getResizedAvatar = (author, sizeString = 'small') => {
if (!author) return ''; if (!author) {
return '';
}
return `https://steemitimages.com/u/${author}/avatar/${sizeString}`; return `https://steemitimages.com/u/${author}/avatar/${sizeString}`;
}; };

View File

@ -1,5 +1,7 @@
export const jsonStringify = jsonMetadata => { export const jsonStringify = jsonMetadata => {
if (!jsonMetadata) return ''; if (!jsonMetadata) {
return '';
}
try { try {
return JSON.stringify(jsonMetadata); return JSON.stringify(jsonMetadata);

View File

@ -18,7 +18,9 @@ export const getVotingPower = account => {
let currentMana = Number(manabar.current_mana) + (elapsed * maxMana) / PERIOD; let currentMana = Number(manabar.current_mana) + (elapsed * maxMana) / PERIOD;
if (currentMana > maxMana) currentMana = maxMana; if (currentMana > maxMana) {
currentMana = maxMana;
}
return (currentMana * 100) / maxMana; return (currentMana * 100) / maxMana;
}; };
@ -38,7 +40,9 @@ export const getRcPower = account => {
let currentMana = Number(manabar.current_mana) + (elapsed * maxMana) / PERIOD; let currentMana = Number(manabar.current_mana) + (elapsed * maxMana) / PERIOD;
if (currentMana > maxMana) currentMana = maxMana; if (currentMana > maxMana) {
currentMana = maxMana;
}
return (currentMana * 100) / maxMana; return (currentMana * 100) / maxMana;
}; };

View File

@ -1,7 +1,11 @@
export const countDecimals = value => { export const countDecimals = value => {
if (!value) return 0; if (!value) {
return 0;
}
if (Math.floor(value) === value) return 0; if (Math.floor(value) === value) {
return 0;
}
return value.toString().split('.')[1].length || 0; return value.toString().split('.')[1].length || 0;
}; };

View File

@ -1,5 +1,7 @@
export default strVal => { export default strVal => {
if (!strVal) return 0; if (!strVal) {
return 0;
}
return Number(parseFloat(strVal.split(' ')[0])); return Number(parseFloat(strVal.split(' ')[0]));
}; };

View File

@ -1,5 +1,7 @@
export const getReputation = reputation => { export const getReputation = reputation => {
if (reputation === null) return reputation; if (reputation === null) {
return reputation;
}
let _reputation = String(parseInt(reputation, 10)); let _reputation = String(parseInt(reputation, 10));
@ -13,7 +15,9 @@ export const getReputation = reputation => {
let out = n + (log - parseInt(log, 10)); let out = n + (log - parseInt(log, 10));
// eslint-disable-next-line no-restricted-globals // eslint-disable-next-line no-restricted-globals
if (isNaN(out)) out = 0; if (isNaN(out)) {
out = 0;
}
out = Math.max(out - 9, 0); out = Math.max(out - 9, 0);
out *= neg ? -1 : 1; out *= neg ? -1 : 1;

View File

@ -2,7 +2,9 @@ export const groomingServerName = (serverName, prefix1) => {
const PREFIX1 = prefix1 || 'https://'; const PREFIX1 = prefix1 || 'https://';
const PREFIX2 = 'https://'; const PREFIX2 = 'https://';
if (!serverName) return null; if (!serverName) {
return null;
}
if (serverName.indexOf(PREFIX1) === 0) { if (serverName.indexOf(PREFIX1) === 0) {
return serverName.substr(PREFIX1.length); return serverName.substr(PREFIX1.length);

View File

@ -9,14 +9,20 @@ export const getReputation = input => {
let neg = false; let neg = false;
if (input < 0) neg = true; if (input < 0) {
neg = true;
}
let reputationLevel = Math.log10(Math.abs(input)); let reputationLevel = Math.log10(Math.abs(input));
reputationLevel = Math.max(reputationLevel - 9, 0); reputationLevel = Math.max(reputationLevel - 9, 0);
if (reputationLevel < 0) reputationLevel = 0; if (reputationLevel < 0) {
reputationLevel = 0;
}
if (neg) reputationLevel *= -1; if (neg) {
reputationLevel *= -1;
}
reputationLevel = reputationLevel * 9 + 25; reputationLevel = reputationLevel * 9 + 25;