Skip to content

Commit 1b8ca8d

Browse files
committed
fix(rn): device info pull to refresh
Signed-off-by: Godefroy Ponsinet <godefroy.ponsinet@outlook.com>
1 parent 56cb86b commit 1b8ca8d

File tree

1 file changed

+28
-6
lines changed
  • client/react-native/common/components/Screens/Settings/Devtools

1 file changed

+28
-6
lines changed

client/react-native/common/components/Screens/Settings/Devtools/DeviceInfos.js

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1+
import {
2+
Clipboard,
3+
RefreshControl,
4+
ScrollView,
5+
Text,
6+
TouchableOpacity,
7+
} from 'react-native'
18
import React, { PureComponent } from 'react'
2-
import { Text, ScrollView, TouchableOpacity, Clipboard } from 'react-native'
9+
10+
import { GetDeviceInfos } from '../../../../graphql/queries'
311
import { Header } from '../../../Library'
412
import { colors } from '../../../../constants'
513
import { padding } from '../../../../styles'
6-
import { GetDeviceInfos } from '../../../../graphql/queries'
714

815
export default class DeviceInfos extends PureComponent {
916
static navigationOptions = ({ navigation }) => ({
@@ -19,12 +26,19 @@ export default class DeviceInfos extends PureComponent {
1926

2027
state = {
2128
infos: {},
29+
refreshing: false,
30+
}
31+
32+
fetch = () => {
33+
this.setState({ refreshing: true }, () =>
34+
GetDeviceInfos.then(data => {
35+
this.setState({ infos: data.DeviceInfos.infos, refreshing: false })
36+
})
37+
)
2238
}
2339

2440
componentDidMount () {
25-
GetDeviceInfos.then(data => {
26-
this.setState({ infos: data.DeviceInfos.infos })
27-
})
41+
this.fetch()
2842
}
2943

3044
render () {
@@ -60,7 +74,15 @@ export default class DeviceInfos extends PureComponent {
6074
}
6175

6276
return (
63-
<ScrollView style={{ backgroundColor: colors.background }}>
77+
<ScrollView
78+
style={{ backgroundColor: colors.background }}
79+
refreshControl={
80+
<RefreshControl
81+
refreshing={this.state.refreshing}
82+
onRefresh={this.fetch}
83+
/>
84+
}
85+
>
6486
{fields}
6587
</ScrollView>
6688
)

0 commit comments

Comments
 (0)