mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-24 13:53:23 +03:00
Merge pull request #2332 from ecency/sa/boot-screen-url-validate
Validate ecency url in boost screen
This commit is contained in:
commit
90dc8f92d9
@ -21,6 +21,8 @@ import { Modal } from '../modal';
|
|||||||
// Styles
|
// Styles
|
||||||
import styles from './postBoostStyles';
|
import styles from './postBoostStyles';
|
||||||
import { OptionsModal } from '../atoms';
|
import { OptionsModal } from '../atoms';
|
||||||
|
import { deepLinkParser } from '../../utils/deepLinkParser';
|
||||||
|
import postUrlParser from '../../utils/postUrlParser';
|
||||||
|
|
||||||
class BoostPostScreen extends PureComponent {
|
class BoostPostScreen extends PureComponent {
|
||||||
/* Props
|
/* Props
|
||||||
@ -40,6 +42,7 @@ class BoostPostScreen extends PureComponent {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.startActionSheet = React.createRef();
|
this.startActionSheet = React.createRef();
|
||||||
|
this.urlInputRef = React.createRef();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Component Life Cycles
|
// Component Life Cycles
|
||||||
@ -112,6 +115,21 @@ class BoostPostScreen extends PureComponent {
|
|||||||
handleOnSubmit(redeemType, amount, fullPermlink, selectedUser);
|
handleOnSubmit(redeemType, amount, fullPermlink, selectedUser);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
_validateUrl = () => {
|
||||||
|
const { permlink, isValid } = this.state;
|
||||||
|
if (!isValid) {
|
||||||
|
const postUrl = postUrlParser(permlink);
|
||||||
|
if (postUrl && postUrl.author && postUrl.permlink) {
|
||||||
|
let postPermlink = `${postUrl.author}/${postUrl.permlink}`;
|
||||||
|
this.setState({
|
||||||
|
permlink: postPermlink,
|
||||||
|
isValid: true,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.setState({ isValid: false });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
render() {
|
render() {
|
||||||
const { intl } = this.props;
|
const { intl } = this.props;
|
||||||
const { selectedUser, balance, factor, permlinkSuggestions, permlink, isValid } = this.state;
|
const { selectedUser, balance, factor, permlinkSuggestions, permlink, isValid } = this.state;
|
||||||
@ -126,15 +144,16 @@ class BoostPostScreen extends PureComponent {
|
|||||||
isSCModalOpen,
|
isSCModalOpen,
|
||||||
handleOnSCModalClose,
|
handleOnSCModalClose,
|
||||||
getESTMPrice,
|
getESTMPrice,
|
||||||
|
user,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
const calculatedESTM = 150 + 50 * factor;
|
const calculatedESTM = 150 + 50 * factor;
|
||||||
|
// console.log('this.state.permlink : ', this.state.permlink);
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<BasicHeader title={intl.formatMessage({ id: 'boostPost.title' })} />
|
<BasicHeader title={intl.formatMessage({ id: 'boostPost.title' })} />
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
<ScrollView>
|
<ScrollView keyboardShouldPersistTaps="handled">
|
||||||
<View style={styles.middleContent}>
|
<View style={styles.middleContent}>
|
||||||
<TransferFormItem
|
<TransferFormItem
|
||||||
label={intl.formatMessage({ id: 'promote.user' })}
|
label={intl.formatMessage({ id: 'promote.user' })}
|
||||||
@ -166,18 +185,22 @@ class BoostPostScreen extends PureComponent {
|
|||||||
placeholder={intl.formatMessage({ id: 'promote.permlinkPlaceholder' })}
|
placeholder={intl.formatMessage({ id: 'promote.permlinkPlaceholder' })}
|
||||||
placeholderTextColor="#c1c5c7"
|
placeholderTextColor="#c1c5c7"
|
||||||
autoCapitalize="none"
|
autoCapitalize="none"
|
||||||
|
returnKeyType="done"
|
||||||
|
onBlur={() => this._validateUrl()}
|
||||||
|
innerRef={this.urlInputRef}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
renderItem={({ item }) => (
|
renderItem={({ item }) => (
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
key={item}
|
key={item}
|
||||||
onPress={() =>
|
onPress={() => {
|
||||||
|
this.urlInputRef.current?.blur();
|
||||||
this.setState({
|
this.setState({
|
||||||
permlink: item,
|
permlink: item,
|
||||||
isValid: true,
|
isValid: true,
|
||||||
permlinkSuggestions: [],
|
permlinkSuggestions: [],
|
||||||
})
|
});
|
||||||
}
|
}}
|
||||||
>
|
>
|
||||||
<Text style={styles.autocompleteItemText}>{item}</Text>
|
<Text style={styles.autocompleteItemText}>{item}</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
|
@ -24,6 +24,7 @@ class RedeemScreen extends PureComponent {
|
|||||||
navigationParams,
|
navigationParams,
|
||||||
redeemType,
|
redeemType,
|
||||||
getESTMPrice,
|
getESTMPrice,
|
||||||
|
user,
|
||||||
}) => (
|
}) => (
|
||||||
<RedeemContainer>
|
<RedeemContainer>
|
||||||
{({ handleOnSubmit, SCPath, isSCModalOpen, handleOnSCModalClose, isLoading }) => (
|
{({ handleOnSubmit, SCPath, isSCModalOpen, handleOnSCModalClose, isLoading }) => (
|
||||||
@ -57,6 +58,7 @@ class RedeemScreen extends PureComponent {
|
|||||||
handleOnSCModalClose={handleOnSCModalClose}
|
handleOnSCModalClose={handleOnSCModalClose}
|
||||||
SCPath={SCPath}
|
SCPath={SCPath}
|
||||||
getESTMPrice={getESTMPrice}
|
getESTMPrice={getESTMPrice}
|
||||||
|
user={user}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</Fragment>
|
</Fragment>
|
||||||
|
Loading…
Reference in New Issue
Block a user