diff --git a/client/react-native/common/components/App.js b/client/react-native/common/components/App.js index e9c76510fe..b1c1160803 100644 --- a/client/react-native/common/components/App.js +++ b/client/react-native/common/components/App.js @@ -9,7 +9,7 @@ import ReactNativeLanguages from 'react-native-languages' import { BASE_WEBSITE_URL, colors } from './../constants' import { Flex, Animation } from './Library' -import { conversation } from '../utils' +import { contact, conversation } from '../utils' import { parse as parseUrl } from '../helpers/url' import Accounts from './Screens/Accounts' import Instabug from '../helpers/Instabug' @@ -96,6 +96,9 @@ export default class App extends PureComponent { }) break case '/modal/contacts/card': + if (url.hashParts['id']) { + url.hashParts['id'] = contact.getRelayID(url.hashParts['id']) + } this.setState({ deepLink: { routeName: 'modal/contacts/card', diff --git a/client/react-native/common/components/Library/ContactIdentity.js b/client/react-native/common/components/Library/ContactIdentity.js index d15a8350ee..5619c44d9e 100644 --- a/client/react-native/common/components/Library/ContactIdentity.js +++ b/client/react-native/common/components/Library/ContactIdentity.js @@ -1,60 +1,71 @@ -import React from 'react' import { View, Platform, Text as RNText } from 'react-native' -import { Avatar, Text } from '.' import { createMaterialTopTabNavigator } from 'react-navigation' -import QRGenerator from './QRGenerator' -import { makeShareableUrl } from '../../helpers/contacts' -import colors from '../../constants/colors' +import I18n from 'i18next' +import React from 'react' + +import { Avatar, Text } from '.' +import { contact } from '../../utils' import { formattedFingerprint } from '../../helpers/fingerprint' +import { makeShareableUrl } from '../../helpers/contacts' +import { monospaceFont, tabNavigatorOptions } from '../../constants/styling' import { padding } from '../../styles' import { tabIcon, withScreenProps } from '../../helpers/views' -import { monospaceFont, tabNavigatorOptions } from '../../constants/styling' -import I18n from 'i18next' +import QRGenerator from './QRGenerator' +import colors from '../../constants/colors' -const PublicKey = ({ data: { id } }) => - {id} - +const PublicKey = ({ data: { id } }) => ( + + + {contact.getCoreID(id)} + + +) -const QrCode = ({ data: { id, displayName } }) => - - +const QrCode = ({ data: { id, displayName } }) => ( + + + +) -const Fingerprint = ({ data: { id } }) => - - {formattedFingerprint(id)} - - +const Fingerprint = ({ data: { id } }) => ( + + + {formattedFingerprint(id)} + + +) const ContactIdentityTabbedContent = createMaterialTopTabNavigator( { - 'qrcode': { + qrcode: { screen: withScreenProps(QrCode), navigationOptions: () => ({ title: I18n.t('qrcode'), @@ -68,7 +79,7 @@ const ContactIdentityTabbedContent = createMaterialTopTabNavigator( tabBarIcon: tabIcon('material-key-variant'), }), }, - 'fingerprint': { + fingerprint: { screen: withScreenProps(Fingerprint), navigationOptions: () => ({ title: I18n.t('fingerprint'), @@ -79,19 +90,29 @@ const ContactIdentityTabbedContent = createMaterialTopTabNavigator( { initialRouteName: 'qrcode', ...tabNavigatorOptions, - }, + } ) -const ContactIdentity = ({ data }) => <> - - - - {data.displayName} - - {} - - +const ContactIdentity = ({ data }) => ( + <> + + + + + {data.displayName} + + + {} + + +) export default ContactIdentity ContactIdentity.QrCode = QrCode diff --git a/client/react-native/common/components/Library/ContactIdentityActions/index.js b/client/react-native/common/components/Library/ContactIdentityActions/index.js index 84109d32e4..aa80488362 100644 --- a/client/react-native/common/components/Library/ContactIdentityActions/index.js +++ b/client/react-native/common/components/Library/ContactIdentityActions/index.js @@ -1,47 +1,43 @@ import React from 'react' -import { WithContact } from '../../../utils/contact' import { enums } from '../../../graphql' -import { Text, View, ActivityIndicator } from 'react-native' +import { Text, View } from 'react-native' import { withNavigation } from 'react-navigation' import ActionsAdd from './ActionsAdd' import ActionsShare from './ActionsShare' import ReceivedActions from './ActionsReceived' import ActionsSent from './ActionsSent' -const ContactIdentityActions = ({ data, navigation, modalWidth }) => - {(user, state) => { - if (state.type === state.error) { - return Error - } else if (state.type !== state.success) { - return - } else if (user === null) { - return - } else { - switch (user.status) { - case enums.BertyEntityContactInputStatus.Myself: - return - - case enums.BertyEntityContactInputStatus.IsFriend: - case enums.BertyEntityContactInputStatus.IsTrustedFriend: - return - - case enums.BertyEntityContactInputStatus.IsRequested: - console.log(user) - return - - case enums.BertyEntityContactInputStatus.RequestedMe: - return - - case enums.BertyEntityContactInputStatus.IsBlocked: - return Is blocked - - case enums.BertyEntityContactInputStatus.Unknown: - default: - return Unknown state - } - } - }} - +const Actions = ({ data, navigation }) => { + if (data == null) { + return + } + switch (data.status) { + case enums.BertyEntityContactInputStatus.Myself: + return + + case enums.BertyEntityContactInputStatus.IsFriend: + case enums.BertyEntityContactInputStatus.IsTrustedFriend: + return + + case enums.BertyEntityContactInputStatus.IsRequested: + return + + case enums.BertyEntityContactInputStatus.RequestedMe: + return + + case enums.BertyEntityContactInputStatus.IsBlocked: + return Is blocked + + case enums.BertyEntityContactInputStatus.Unknown: + default: + return Unknown state + } +} + +const ContactIdentityActions = ({ modalWidth, ...props }) => ( + + + +) export default withNavigation(ContactIdentityActions) diff --git a/client/react-native/common/components/Library/SelfAvatarIcon.js b/client/react-native/common/components/Library/SelfAvatarIcon.js index 07618a6c2e..8e7aa6f411 100644 --- a/client/react-native/common/components/Library/SelfAvatarIcon.js +++ b/client/react-native/common/components/Library/SelfAvatarIcon.js @@ -1,32 +1,32 @@ -import React, { PureComponent } from 'react' import { TouchableOpacity } from 'react-native' +import React, { PureComponent } from 'react' + import { Avatar, Header } from '.' import { colors } from '../../constants' +import { contact } from '../../utils' import { withCurrentUser } from '../../utils/contact' -import { extractPublicKeyFromId } from '../../helpers/contacts' import NavigationService from '../../helpers/NavigationService' class SelfAvatarLink extends PureComponent { - onPress = (data) => { - NavigationService.navigate('modal/contacts/card', { - data, - }) + onPress = data => { + NavigationService.navigate('modal/contacts/card', data) } render = () => { let user = this.props.currentUser - user = user ? { ...user, id: extractPublicKeyFromId(user.id) } : null - return user - ? this.onPress(user)}> - + return user ? ( + this.onPress(user)}> + - : + ) } } diff --git a/client/react-native/common/components/Screens/Accounts/Current.js b/client/react-native/common/components/Screens/Accounts/Current.js index ab97b8b133..35e8d46ee2 100644 --- a/client/react-native/common/components/Screens/Accounts/Current.js +++ b/client/react-native/common/components/Screens/Accounts/Current.js @@ -112,7 +112,9 @@ class Current extends PureComponent { ) { let val = route.params[key] if (key === 'id') { - val = atob(val).match(/:(.*)$/)[1] + val = atob(val) + val = val.match(/:(.*)$/) + val = val[1] } fragment += fragment.length > 0 ? `,${key}=${val}` : `#${key}=${val}` } diff --git a/client/react-native/common/components/Screens/Contacts/ContactCardModal.js b/client/react-native/common/components/Screens/Contacts/ContactCardModal.js index 4d32779e73..993690e456 100644 --- a/client/react-native/common/components/Screens/Contacts/ContactCardModal.js +++ b/client/react-native/common/components/Screens/Contacts/ContactCardModal.js @@ -1,39 +1,64 @@ -import React from 'react' -import { withNavigation } from 'react-navigation' import { View } from 'react-native' +import { withNavigation } from 'react-navigation' +import React from 'react' + import { - ContactIdentityActions, ContactIdentity, + ContactIdentityActions, + Loader, ModalScreen, } from '../../Library' +import { QueryReducer, RelayContext } from '../../../relay' +import { merge } from '../../../helpers' const modalWidth = 320 const ContactCardModal = ({ navigation }) => { const id = navigation.getParam('id') - const displayName = navigation.getParam('displayName') - return ( - - - } - > - - - + + {context => ( + + {state => { + switch (state.type) { + case state.loading: + return + case state.success: + return ( + + + } + > + + + + ) + case state.error: + return + } + }} + + )} + ) } diff --git a/client/react-native/common/components/Screens/Contacts/Detail/Detail.js b/client/react-native/common/components/Screens/Contacts/Detail/Detail.js index 42d206119a..fe3e36bddc 100644 --- a/client/react-native/common/components/Screens/Contacts/Detail/Detail.js +++ b/client/react-native/common/components/Screens/Contacts/Detail/Detail.js @@ -1,10 +1,10 @@ -import React, { PureComponent } from 'react' import { ActionSheetIOS, Platform, Alert } from 'react-native' -import { Menu, Header, Screen, Avatar } from '../../../Library' -import { colors } from '../../../../constants' -import { extractPublicKeyFromId } from '../../../../helpers/contacts' import { withNamespaces } from 'react-i18next' import I18n from 'i18next' +import React, { PureComponent } from 'react' + +import { Menu, Header, Screen, Avatar } from '../../../Library' +import { colors } from '../../../../constants' class Detail extends PureComponent { static navigationOptions = ({ navigation }) => ({ @@ -84,9 +84,7 @@ class Detail extends PureComponent { - } + icon={} title={contact.overrideDisplayName || contact.displayName} /> @@ -107,10 +105,7 @@ class Detail extends PureComponent { title={t('contacts.view-pub-key')} onPress={() => navigation.navigate('modal/contacts/card', { - data: { - ...contact, - id: extractPublicKeyFromId(contact.id), - }, + id: contact.id, }) } /> diff --git a/client/react-native/common/utils/contact.js b/client/react-native/common/utils/contact.js index 15db1ad997..29794d1294 100644 --- a/client/react-native/common/utils/contact.js +++ b/client/react-native/common/utils/contact.js @@ -3,7 +3,7 @@ import { View } from 'react-native' import { QueryReducer } from '../relay' import { merge } from '../helpers' import RelayContext from '../relay/RelayContext' -import { btoa } from 'b64-lite' +import { btoa, atob } from 'b64-lite' const defaultValuesContact = { id: '', diff --git a/client/react-native/common/utils/conversation.js b/client/react-native/common/utils/conversation.js index 2459c87cd7..3b0114f5f5 100644 --- a/client/react-native/common/utils/conversation.js +++ b/client/react-native/common/utils/conversation.js @@ -1,3 +1,5 @@ +import { btoa, atob } from 'b64-lite' + export default { id: '', title: '', diff --git a/core/node/event_handlers.go b/core/node/event_handlers.go index 91d7ecf3ed..76c9026a87 100644 --- a/core/node/event_handlers.go +++ b/core/node/event_handlers.go @@ -51,7 +51,7 @@ func (n *Node) handleContactRequest(ctx context.Context, input *entity.Event) er Body: i18n.T("ContactRequestBody", map[string]interface{}{ "Name": attrs.Me.DisplayName, }), - DeepLink: "berty://berty.chat/modal/contacts/card#public-key=" + url.PathEscape(attrs.Me.ID) + "&display-name=" + url.PathEscape(attrs.Me.DisplayName), + DeepLink: "berty://berty.chat/modal/contacts/card#id=" + url.PathEscape(attrs.Me.ID) + "&display-name=" + url.PathEscape(attrs.Me.DisplayName), }) if err := entity.SaveDevices(sql, attrs.Me.ID, devices); err != nil {