Skip to content

Commit

Permalink
fix(rn): contact modal card, use navigation data for unknown entity
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 Jun 7, 2019
1 parent 1c246f2 commit f050994
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 57 deletions.
54 changes: 9 additions & 45 deletions client/react-native/app/container/container.gen.js
Expand Up @@ -10,11 +10,7 @@ import { Component } from 'react'
export class ConfigEntity extends Component {
render () {
const { context, id, children } = this.props
const entity = context.entity.config.get(id)
if (entity) {
return children(entity)
}
return null
return children(context.entity.config.get(id))
}
}

Expand All @@ -23,11 +19,7 @@ export class ConfigEntity extends Component {
export class ContactEntity extends Component {
render () {
const { context, id, children } = this.props
const entity = context.entity.contact.get(id)
if (entity) {
return children(entity)
}
return null
return children(context.entity.contact.get(id))
}
}

Expand All @@ -36,11 +28,7 @@ export class ContactEntity extends Component {
export class DeviceEntity extends Component {
render () {
const { context, id, children } = this.props
const entity = context.entity.device.get(id)
if (entity) {
return children(entity)
}
return null
return children(context.entity.device.get(id))
}
}

Expand All @@ -49,11 +37,7 @@ export class DeviceEntity extends Component {
export class ConversationEntity extends Component {
render () {
const { context, id, children } = this.props
const entity = context.entity.conversation.get(id)
if (entity) {
return children(entity)
}
return null
return children(context.entity.conversation.get(id))
}
}

Expand All @@ -62,11 +46,7 @@ export class ConversationEntity extends Component {
export class ConversationMemberEntity extends Component {
render () {
const { context, id, children } = this.props
const entity = context.entity.conversationMember.get(id)
if (entity) {
return children(entity)
}
return null
return children(context.entity.conversationMember.get(id))
}
}

Expand All @@ -75,11 +55,7 @@ export class ConversationMemberEntity extends Component {
export class EventEntity extends Component {
render () {
const { context, id, children } = this.props
const entity = context.entity.event.get(id)
if (entity) {
return children(entity)
}
return null
return children(context.entity.event.get(id))
}
}

Expand All @@ -88,11 +64,7 @@ export class EventEntity extends Component {
export class DevicePushConfigEntity extends Component {
render () {
const { context, id, children } = this.props
const entity = context.entity.devicePushConfig.get(id)
if (entity) {
return children(entity)
}
return null
return children(context.entity.devicePushConfig.get(id))
}
}

Expand All @@ -101,11 +73,7 @@ export class DevicePushConfigEntity extends Component {
export class DevicePushIdentifierEntity extends Component {
render () {
const { context, id, children } = this.props
const entity = context.entity.devicePushIdentifier.get(id)
if (entity) {
return children(entity)
}
return null
return children(context.entity.devicePushIdentifier.get(id))
}
}

Expand All @@ -114,11 +82,7 @@ export class DevicePushIdentifierEntity extends Component {
export class SenderAliasEntity extends Component {
render () {
const { context, id, children } = this.props
const entity = context.entity.senderAlias.get(id)
if (entity) {
return children(entity)
}
return null
return children(context.entity.senderAlias.get(id))
}
}

Expand Down
4 changes: 1 addition & 3 deletions client/react-native/app/relay/utils/contact.js
Expand Up @@ -62,9 +62,7 @@ export const withCurrentUser = (WrappedComponent, opts) => {
variables={merge([
queries.Contact.defaultVariables,
{
filter: {
status: 42,
},
status: 42,
},
])}
>
Expand Down
Expand Up @@ -18,11 +18,7 @@ import { Component } from 'react'
export class {{name}}Entity extends Component {
render () {
const { context, id, children } = this.props
const entity = context.entity.{{case 'camel' name}}.get(id)
if (entity) {
return children(entity)
}
return null
return children(context.entity.{{case 'camel' name}}.get(id))
}
}
{{/if}}
Expand Down
Expand Up @@ -17,15 +17,15 @@ class ContactCardModal extends React.Component {

render () {
const { navigation } = this.props
const data = {
const navigationData = {
id: navigation.getParam('id'),
displayName: navigation.getParam('displayName'),
status: navigation.getParam('status'),
}

return (
<Store.Entity.Contact id={data.id}>
{data => (
<Store.Entity.Contact id={navigationData.id}>
{(data = navigationData) => (
<View
style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}
>
Expand Down
7 changes: 6 additions & 1 deletion core/api/node/graphql/resolver.go
Expand Up @@ -693,13 +693,18 @@ func (r *queryResolver) Contact(
if id != "" {
id = strings.SplitN(id, ":", 2)[1]
}
if status == nil {
var value int32
status = &value
}
if devices != nil && len(devices) != 0 {
for i := range devices {
devices[i].ID = strings.SplitN(devices[i].ID, ":", 2)[1]
}
}
return r.client.Contact(ctx, &entity.Contact{
ID: id,
ID: id,
Status: entity.Contact_Status(*status),
})
}
func (r *queryResolver) ConversationList(ctx context.Context, filter *entity.Conversation, orderBy string, orderDesc bool, first *int32, after *string, last *int32, before *string) (*node.ConversationListConnection, error) {
Expand Down

0 comments on commit f050994

Please sign in to comment.