Skip to content

Commit

Permalink
fix(rn): fetch device infos
Browse files Browse the repository at this point in the history
Signed-off-by: Godefroy Ponsinet <godefroy.ponsinet@outlook.com>
  • Loading branch information
90dy committed Oct 30, 2018
1 parent 1aca191 commit e3a4f20
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
Expand Up @@ -7,7 +7,7 @@ import {
} from 'react-native'
import React, { PureComponent } from 'react'

import { GetDeviceInfos } from '../../../../graphql/queries'
import { DeviceInfos as GetDeviceInfos } from '../../../../graphql/queries'
import { Header } from '../../../Library'
import { colors } from '../../../../constants'
import { padding } from '../../../../styles'
Expand All @@ -30,11 +30,10 @@ export default class DeviceInfos extends PureComponent {
}

fetch = () => {
this.setState({ refreshing: true }, () =>
GetDeviceInfos.then(data => {
this.setState({ infos: data.DeviceInfos.infos, refreshing: false })
})
)
this.setState({ refreshing: true }, async () => {
const data = await GetDeviceInfos.fetch()
this.setState({ infos: data.DeviceInfos.infos, refreshing: false })
})
}

componentDidMount () {
Expand Down
6 changes: 5 additions & 1 deletion client/react-native/common/graphql/queries/DeviceInfos.js
Expand Up @@ -12,4 +12,8 @@ const query = graphql`
}
`

export default fetchQuery(environment, query, { t: true })
export default {
...query,
fetch: (variables = {}) =>
fetchQuery(environment, query, { t: true, ...variables }),
}
2 changes: 1 addition & 1 deletion client/react-native/common/graphql/queries/index.js
@@ -1,6 +1,6 @@
export ConversationList from './ConversationList'
export ContactList from './ContactList'
export Contact from './Contact'
export GetDeviceInfos from './DeviceInfos'
export DeviceInfos from './DeviceInfos'
export AppVersion from './AppVersion'
export EventList from './EventList'

0 comments on commit e3a4f20

Please sign in to comment.