Skip to content

Commit

Permalink
Merge pull request #1128 from sfroment/dev/sfroment/#1127
Browse files Browse the repository at this point in the history
feat(core): add title/topics modification
  • Loading branch information
sfroment committed Mar 14, 2019
2 parents a445bc0 + 457f2d1 commit e1780e6
Show file tree
Hide file tree
Showing 24 changed files with 979 additions and 247 deletions.
1 change: 1 addition & 0 deletions client/react-native/common/components/Library/Avatar.js
Expand Up @@ -19,6 +19,7 @@ const Avatar = ({ data, size = 40, margin = 4, uri = null, style = [] }) => {

if (!data || !data.id) {
console.error(['No id provided', data])
return null
}

const extractedPublicKey = extractPublicKeyFromId(data.id)
Expand Down
25 changes: 24 additions & 1 deletion client/react-native/common/components/Screens/Chats/Detail.js
Expand Up @@ -2,6 +2,7 @@ import {
ActivityIndicator,
Platform,
TextInput as RNTextInput,
View,
} from 'react-native'
import { btoa } from 'b64-lite'
import { withNamespaces } from 'react-i18next'
Expand Down Expand Up @@ -304,7 +305,29 @@ class Detail extends PureComponent {
header: (
<Header
navigation={navigation}
title={utils.getTitle(navigation.state.params || {})}
title={(
<View style={{ flexDirection: 'column' }}>
<Text
large
color={colors.fakeBlack}
justify={navigation.getParam('backBtn') ? 'center' : 'start'}
middle
size={5}
>
{utils.getTitle(navigation.state.params) || {}}
</Text>
{navigation.state.params.topic
? (
<Text
justify={navigation.getParam('backBtn') ? 'center' : 'start'}
middle
>
{navigation.state.params.topic}
</Text>
) : null
}
</View>
)}
rightBtnIcon='settings'
onPressRightBtn={() =>
navigation.navigate('chats/settings', {
Expand Down
Expand Up @@ -11,8 +11,17 @@ import withRelayContext from '../../../../helpers/withRelayContext'
import { withGoBack } from '../../../Library/BackActionProvider'

class ListBase extends PureComponent {
state = {
edit: false,
constructor (props) {
super(props)
const conversation = props.navigation.getParam('conversation')
const title = utils.getTitle(conversation)

this.state = {
edit: false,
topic: conversation.topic,
title,
conversation,
}
}

componentDidMount () {
Expand All @@ -29,6 +38,15 @@ class ListBase extends PureComponent {
}

onSave = () => {
const { title, topic, conversation } = this.state
const { context: { mutations } } = this.props

mutations.conversationUpdate({
...conversation,
title,
topic,
})

this.setState({ edit: false }, () =>
this.props.navigation.setParams({ state: this.state })
)
Expand Down Expand Up @@ -63,9 +81,8 @@ class ListBase extends PureComponent {

render () {
const { navigation, t, context } = this.props
const { edit } = this.state
const conversation = this.props.navigation.getParam('conversation')
const title = utils.getTitle(conversation)
const { edit, conversation, title, topic } = this.state

this.context = context
return (
<Screen>
Expand All @@ -92,7 +109,18 @@ class ListBase extends PureComponent {
/>
{edit && (
<Menu.Section title={t('chats.name')}>
<Menu.Input value={title} />
<Menu.Input
value={title}
onChangeText={title => this.setState({ title })}
/>
</Menu.Section>
)}
{edit && (
<Menu.Section title={t('chats.topic')}>
<Menu.Input
value={topic}
onChangeText={topic => this.setState({ topic })}
/>
</Menu.Section>
)}
{!edit && (
Expand Down
2 changes: 2 additions & 0 deletions client/react-native/common/graphql/enums.gen.js
Expand Up @@ -205,6 +205,7 @@ export const BertyEntityKindInputKind = {
ConversationInvite: 301,
ConversationNewMessage: 302,
ConversationRead: 303,
ConversationUpdate: 304,
DevtoolsMapset: 401,
SenderAliasUpdate: 501,
DeviceUpdatePushConfig: 601,
Expand All @@ -225,6 +226,7 @@ export const ValueBertyEntityKindInputKind = {
301: 'ConversationInvite',
302: 'ConversationNewMessage',
303: 'ConversationRead',
304: 'ConversationUpdate',
401: 'DevtoolsMapset',
501: 'SenderAliasUpdate',
601: 'DeviceUpdatePushConfig',
Expand Down
72 changes: 72 additions & 0 deletions client/react-native/common/graphql/mutations/ConversationUpdate.js
@@ -0,0 +1,72 @@
import { graphql } from 'react-relay'

import { commit } from '../../relay'
// import { updaters } from '..'

const ConversationUpdateMutation = graphql`
mutation ConversationUpdateMutation(
$id: ID!
$createdAt: GoogleProtobufTimestampInput
$updatedAt: GoogleProtobufTimestampInput
$readAt: GoogleProtobufTimestampInput
$title: String!
$topic: String!
$infos: String!
$members: [BertyEntityConversationMemberInput]
) {
ConversationUpdate(
id: $id
createdAt: $createdAt
updatedAt: $updatedAt
readAt: $readAt
title: $title
topic: $topic
infos: $infos
members: $members
) {
...Conversation
id
createdAt
updatedAt
title
topic
members {
id
createdAt
updatedAt
status
contact {
id
createdAt
updatedAt
sigchain
status
devices {
id
createdAt
updatedAt
name
status
apiVersion
contactId
}
displayName
displayStatus
overrideDisplayName
overrideDisplayStatus
}
conversationId
contactId
}
}
}
`

export default context => (input, configs) =>
commit(
context.environment,
ConversationUpdateMutation,
'ConversationUpdate',
input,
configs,
)
1 change: 1 addition & 0 deletions client/react-native/common/graphql/mutations/index.js
Expand Up @@ -9,6 +9,7 @@ export conversationAddMessage from './ConversationAddMessage'
export conversationInvite from './ConversationInvite'
export conversationRead from './ConversationRead'
export conversationRemove from './ConversationRemove'
export conversationUpdate from './ConversationUpdate'
export eventSeen from './EventSeen'
export debugRequeueEvent from './DebugRequeueEvent'
export debugRequeueAll from './DebugRequeueAll'
Expand Down
1 change: 1 addition & 0 deletions client/react-native/common/i18n/en/messages.json
Expand Up @@ -110,6 +110,7 @@
},
"chats": {
"title": "Chats",
"topic": "Topic",
"no-new-messages": "No new messages",
"new-conversation": "New conversation",
"new-message": "New message",
Expand Down
1 change: 1 addition & 0 deletions client/react-native/common/i18n/fr/messages.json
Expand Up @@ -110,6 +110,7 @@
},
"chats": {
"title": "Conversations",
"topic": "Sujet",
"no-new-messages": "Pas de nouveaux messages",
"new-conversation": "Nouvelle conversation",
"new-message": "Nouveau message",
Expand Down
13 changes: 13 additions & 0 deletions client/react-native/common/schema.graphql

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions client/react-native/desktop/Makefile
Expand Up @@ -5,6 +5,7 @@ deps:
GO111MODULE=off go get -u github.com/asticode/go-astilectron-bundler/...

build:
GOPROXY=https://goproxy.berty.io GO111MODULE=on go mod vendor
sed s%TMPL_MAKEFILE_PATH%$(MAKEFILE_DIR)%g bundler.json.tmpl > bundler.json
cp -rf ../web/build ../desktop/resources/app
GOCACHE=/tmp/gocache astilectron-bundler -v
Expand Down
21 changes: 21 additions & 0 deletions core/api/client/jsonclient/berty.node.service.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions core/api/node/graphql/enums.gen.js
Expand Up @@ -205,6 +205,7 @@ export const BertyEntityKindInputKind = {
ConversationInvite: 301,
ConversationNewMessage: 302,
ConversationRead: 303,
ConversationUpdate: 304,
DevtoolsMapset: 401,
SenderAliasUpdate: 501,
DeviceUpdatePushConfig: 601,
Expand All @@ -225,6 +226,7 @@ export const ValueBertyEntityKindInputKind = {
301: 'ConversationInvite',
302: 'ConversationNewMessage',
303: 'ConversationRead',
304: 'ConversationUpdate',
401: 'DevtoolsMapset',
501: 'SenderAliasUpdate',
601: 'DeviceUpdatePushConfig',
Expand Down
13 changes: 13 additions & 0 deletions core/api/node/graphql/gqlgen.gen.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e1780e6

Please sign in to comment.