Skip to content

Commit

Permalink
chore(rn): destroy relay graphql and permit to build
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 Jul 3, 2019
1 parent 54611d4 commit f9fea76
Show file tree
Hide file tree
Showing 36 changed files with 1,135 additions and 2,438 deletions.
1,136 changes: 0 additions & 1,136 deletions client/react-native/app/schema.graphql

This file was deleted.

3 changes: 1 addition & 2 deletions client/react-native/app/update/package.json
Expand Up @@ -7,7 +7,6 @@
"source": true,
"private": true,
"dependencies": {
"@berty/common": "^0.0.1",
"@berty/graphql": "^0.0.1"
"@berty/common": "^0.0.1"
}
}
4 changes: 2 additions & 2 deletions client/react-native/app/update/update.js
@@ -1,4 +1,3 @@
import { DeviceInfos } from '@berty/graphql/queries'
import { requestAndroidPermission } from '@berty/common/helpers/permissions'
import RNFetchBlob from '@berty/common/helpers/rn-fetch-blob'

Expand Down Expand Up @@ -71,7 +70,8 @@ export const getInstalledVersion = async context => {
}

const { channel } = updateApiSources[bundleId]
const deviceData = await DeviceInfos(context).fetch()
// @FIXME: destroyed by refactor
const deviceData = [{ key: 'versions', value: 'destroyed by refactor' }] // await DeviceInfos(context).fetch()

const [rawVersionInfo] = deviceData.infos
.filter(d => d.key === 'versions')
Expand Down
8 changes: 4 additions & 4 deletions client/react-native/app/view/component/ContactIdentity.js
Expand Up @@ -3,7 +3,6 @@ import { createMaterialTopTabNavigator, withNavigation } from 'react-navigation'
import I18n from 'i18next'
import React from 'react'

import { contact } from '@berty/relay/utils'
import { formattedFingerprint } from '@berty/common/helpers/fingerprint'
import { makeShareableUrl } from '@berty/common/helpers/contacts'
import {
Expand Down Expand Up @@ -108,11 +107,12 @@ const ContactIdentityTabbedContent = createMaterialTopTabNavigator(
}
)

class ContactIdentityBase extends React.Component {
@withNavigation
class ContactIdentity extends React.Component {
static router = ContactIdentityTabbedContent.router

render () {
const { data = contact.default, navigation } = this.props
const { data = {}, navigation } = this.props

return (
<>
Expand Down Expand Up @@ -140,4 +140,4 @@ class ContactIdentityBase extends React.Component {
}
}

export default withNavigation(ContactIdentityBase)
export default ContactIdentity
@@ -1,34 +1,29 @@
import React from 'react'
import { colors } from '@berty/common/constants'
import ActionList from './ActionList'
import RelayContext from '@berty/relay/context'
import { withNamespaces } from 'react-i18next'
import { withStoreContext } from '@berty/store/context'

const ReceivedActions = withStoreContext(
({ data: { id }, inModal, t, context }) => (
<RelayContext.Consumer>
{({ mutations }) => (
<ActionList inModal={inModal}>
<ActionList.Action
icon={'check'}
color={colors.blue}
title={t('contacts.accept-action')}
action={() =>
context.node.service.contactAcceptRequest({ contactId: id })
}
successMessage={t('contacts.accept-action-feedback')}
/>
<ActionList.Action
icon={'x'}
color={colors.white}
title={inModal ? t('contacts.decline-action') : null}
action={() => context.node.service.contactRemove({ id })}
successMessage={t('contacts.decline-action-feedback')}
/>
</ActionList>
)}
</RelayContext.Consumer>
<ActionList inModal={inModal}>
<ActionList.Action
icon={'check'}
color={colors.blue}
title={t('contacts.accept-action')}
action={() =>
context.node.service.contactAcceptRequest({ contactId: id })
}
successMessage={t('contacts.accept-action-feedback')}
/>
<ActionList.Action
icon={'x'}
color={colors.white}
title={inModal ? t('contacts.decline-action') : null}
action={() => context.node.service.contactRemove({ id })}
successMessage={t('contacts.decline-action-feedback')}
/>
</ActionList>
)
)

Expand Down
147 changes: 74 additions & 73 deletions client/react-native/app/view/component/DebugStateBar.js
@@ -1,12 +1,10 @@
import React, { PureComponent } from 'react'
import { colors } from '@berty/common/constants'
import { promiseWithTimeout } from 'react-relay-network-modern/es/middlewares/retry'
import Flex from './Flex'
import Text from './Text'
import { View, Platform } from 'react-native'
import Icon from './Icon'
import NavigationService from '@berty/common/helpers/NavigationService'
import { withRelayContext } from '@berty/relay/context'

const daemonStateValues = {
down: 0,
Expand Down Expand Up @@ -46,13 +44,14 @@ class DebugStateBar extends PureComponent {

this.fetchPeers()

this.subscriber = this.props.context.subscriptions.monitorPeers.subscribe({
iterator: undefined,
updater: (store, data) => {
const peer = data.MonitorPeers
this.addPeer(peer)
},
})
// @FIXME: destroyed by refactor
// this.subscriber = this.props.context.subscriptions.monitorPeers.subscribe({
// iterator: undefined,
// updater: (store, data) => {
// const peer = data.MonitorPeers
// this.addPeer(peer)
// },
// })
}

componentWillUnmount () {
Expand Down Expand Up @@ -89,72 +88,74 @@ class DebugStateBar extends PureComponent {
}

fetchListenAddrs = async () => {
const { context } = this.props
const { watchTime, requestTimeout, timeouted } = this.state
try {
const e = await promiseWithTimeout(
context.queries.GetListenAddrs.fetch(),
requestTimeout,
this.timeoutPromise
)
const timer = setTimeout(this.fetchListenAddrs, watchTime)
// if we previously timeouted we need to refetch peers
if (timeouted === true) {
this.fetchPeers()
}
this.setState(
{
listenAddrs: e.addrs,
timeouted: false,
listenAddrTimer: timer,
},
this.setColor
)
} catch (err) {
const timer = setTimeout(this.fetchListenAddrs, watchTime)
this.setState({
listenAddrTimer: timer,
timeouted: true,
listenAddrs: [],
})
// console.warn('err listen address', err)
}
// @FIXME: destroyed by refactor
// const { context } = this.props
// const { watchTime, requestTimeout, timeouted } = this.state
// try {
// const e = await promiseWithTimeout(
// context.queries.GetListenAddrs.fetch(),
// requestTimeout,
// this.timeoutPromise
// )
// const timer = setTimeout(this.fetchListenAddrs, watchTime)
// // if we previously timeouted we need to refetch peers
// if (timeouted === true) {
// this.fetchPeers()
// }
// this.setState(
// {
// listenAddrs: e.addrs,
// timeouted: false,
// listenAddrTimer: timer,
// },
// this.setColor
// )
// } catch (err) {
// const timer = setTimeout(this.fetchListenAddrs, watchTime)
// this.setState({
// listenAddrTimer: timer,
// timeouted: true,
// listenAddrs: [],
// })
// // console.warn('err listen address', err)
// }
}

fetchListenInterfaceAddrs = async () => {
const { context } = this.props
const { watchTime, requestTimeout, timeouted } = this.state
try {
const e = await promiseWithTimeout(
context.queries.GetListenInterfaceAddrs.fetch(),
requestTimeout,
this.timeoutPromise
)
const timer = setTimeout(this.fetchListenInterfaceAddrs, watchTime)
// if we previously timeouted we need to refetch peers
if (timeouted === true) {
this.fetchPeers()
}
this.setState(
{
listenInterfaceAddrs: e.addrs,
timeouted: false,
InterfaceAddrTimer: timer,
},
this.setColor
)
} catch (err) {
const timer = setTimeout(this.fetchListenInterfaceAddrs, watchTime)
this.setState(
{
InterfaceAddrTimer: timer,
timeouted: true,
listenInterfaceAddrs: [],
},
this.setColor
)
// console.warn('err Listen address', err)
}
// @FIXME: destroyed by refactor
// const { context } = this.props
// const { watchTime, requestTimeout, timeouted } = this.state
// try {
// const e = await promiseWithTimeout(
// context.queries.GetListenInterfaceAddrs.fetch(),
// requestTimeout,
// this.timeoutPromise
// )
// const timer = setTimeout(this.fetchListenInterfaceAddrs, watchTime)
// // if we previously timeouted we need to refetch peers
// if (timeouted === true) {
// this.fetchPeers()
// }
// this.setState(
// {
// listenInterfaceAddrs: e.addrs,
// timeouted: false,
// InterfaceAddrTimer: timer,
// },
// this.setColor
// )
// } catch (err) {
// const timer = setTimeout(this.fetchListenInterfaceAddrs, watchTime)
// this.setState(
// {
// InterfaceAddrTimer: timer,
// timeouted: true,
// listenInterfaceAddrs: [],
// },
// this.setColor
// )
// // console.warn('err Listen address', err)
// }
}

setColor = () => {
Expand Down Expand Up @@ -342,4 +343,4 @@ class DebugStateBar extends PureComponent {
}
}

export default withRelayContext(DebugStateBar)
export default DebugStateBar
13 changes: 5 additions & 8 deletions client/react-native/app/view/component/SelfAvatarIcon.js
Expand Up @@ -5,28 +5,25 @@ import { withNavigation } from 'react-navigation'
import Avatar from './Avatar'
import { HeaderButton } from './Header'
import { colors } from '@berty/common/constants'
import { contact } from '@berty/relay/utils'
import { withCurrentUser } from '@berty/relay/utils/contact'

@withNavigation
// @withCurrentUser
class SelfAvatarLink extends PureComponent {
onPress = data => {
this.props.navigation.navigate('modal/contacts/card', {
...data,
id: contact.getCoreID(data.id),
})
this.props.navigation.navigate('modal/contacts/card', data)
}

render = () => {
let user = this.props.currentUser

return user ? (
<TouchableOpacity onPress={() => this.onPress(user)}>
<Avatar data={{ ...user, id: contact.getCoreID(user.id) }} size={24} />
<Avatar data={{ ...user, id: user.id }} size={24} />
</TouchableOpacity>
) : (
<HeaderButton icon={'share'} color={colors.black} justify='end' middle />
)
}
}

export default withNavigation(withCurrentUser(SelfAvatarLink))
export default SelfAvatarLink

0 comments on commit f9fea76

Please sign in to comment.