send tip fix and tweaks #33

Merged
akinwale merged 1 commit from fix-send-tip into master 2019-08-25 17:37:41 +02:00
2 changed files with 12 additions and 6 deletions
package.json
src/page/file

View file

@ -12,7 +12,7 @@
"base-64": "^0.1.0",
"@expo/vector-icons": "^8.1.0",
"gfycat-style-urls": "^1.0.3",
"lbry-redux": "lbryio/lbry-redux#4f812db1c7cdb4c08c5426d4d3f83023de5d655f",
"lbry-redux": "lbryio/lbry-redux#73f10d488d5fd5df7aa806b60c8df5c948ca3c9a",
"lbryinc": "lbryio/lbryinc#17868d948a160af27a375956226f8dd23fa2c37d",
"lodash": ">=4.17.11",
"merge": ">=1.2.1",

View file

@ -70,6 +70,7 @@ class FilePage extends React.PureComponent {
mediaLoaded: false,
pageSuspended: false,
relatedContentY: 0,
sendTipStarted: false,
showDescription: false,
showImageViewer: false,
showWebView: false,
@ -498,7 +499,7 @@ class FilePage extends React.PureComponent {
return;
}
const suffix = 'credit' + (tipAmount === 1 ? '' : 's');
const suffix = 'credit' + (parseInt(tipAmount, 10) === 1 ? '' : 's');
Alert.alert(
'Send tip',
`Are you sure you want to tip ${tipAmount} ${suffix}?`,
@ -507,9 +508,11 @@ class FilePage extends React.PureComponent {
{
text: 'Yes',
onPress: () => {
sendTip(tipAmount, claim.claim_id, false, () => {
this.setState({ tipAmount: 0, showTipView: false });
});
this.setState({ sendTipStarted: true }, () =>
kauffj commented 2019-08-23 16:19:31 +02:00 (Migrated from github.com)

why not force tipAmount to be an int when you are calling setState, rather than converting here? or am I misunderstanding the purpose of this?

why not force `tipAmount` to be an int when you are calling `setState`, rather than converting here? or am I misunderstanding the purpose of this?
akinwale commented 2019-08-23 20:29:29 +02:00 (Migrated from github.com)

The tipAmount value in the state is also used as the value for the TextInput component which only accepts string values. Setting it to an integer in the state results in a warning.

The `tipAmount` value in the state is also used as the value for the `TextInput` component which only accepts string values. Setting it to an integer in the state results in a warning.
kauffj commented 2019-08-23 21:59:13 +02:00 (Migrated from github.com)

Gotcha

Gotcha
sendTip(tipAmount, claim.claim_id, false, () => {
this.setState({ tipAmount: null, showTipView: false, sendTipStarted: false });
})
);
},
},
],
@ -937,16 +940,19 @@ class FilePage extends React.PureComponent {
<View style={filePageStyle.row}>
<View style={filePageStyle.amountRow}>
<TextInput
editable={!this.state.sendTipStarted}
ref={ref => (this.tipAmountInput = ref)}
onChangeText={value => this.setState({ tipAmount: value })}
underlineColorAndroid={Colors.NextLbryGreen}
keyboardType={'numeric'}
placeholder={'0'}
value={this.state.tipAmount}
selectTextOnFocus
style={[filePageStyle.input, filePageStyle.tipAmountInput]}
/>
<Text style={[filePageStyle.text, filePageStyle.currency]}>LBC</Text>
</View>
{this.state.sendTipStarted && <ActivityIndicator size={'small'} color={Colors.NextLbryGreen} />}
<Link
style={[filePageStyle.link, filePageStyle.cancelTipLink]}
text={'Cancel'}
@ -955,7 +961,7 @@ class FilePage extends React.PureComponent {
<Button
text={'Send a tip'}
style={[filePageStyle.button, filePageStyle.sendButton]}
disabled={!canSendTip}
disabled={!canSendTip || this.state.sendTipStarted}
onPress={this.handleSendTip}
/>
</View>