Skip to content

Commit

Permalink
fix(rn): some fixes
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 Dec 11, 2018
1 parent 0f0673c commit 2b70efe
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 60 deletions.
57 changes: 33 additions & 24 deletions client/react-native/Dockerfile
@@ -1,26 +1,35 @@
# Base image
FROM node:10.10.0-alpine

# Create needed directories
RUN mkdir -p /usr/src/app
RUN mkdir /usr/src/app/common
# Web
FROM node:10.14.1-slim as web

# Install watchman
RUN mkdir /var/run/watchman
RUN echo "@testing http://dl-4.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories && \
apk update && apk add --no-cache watchman@testing

# Install common dependencies
COPY common/schema.graphql /usr/src/app/common/schema.graphql
COPY .eslintrc /usr/src/app/.eslintrc
COPY package.json /usr/src/app/package.json
COPY yarn.lock /usr/src/app/yarn.lock
RUN cd /usr/src/app && yarn --silent

# Install web dependencies
COPY web /usr/src/app/web
RUN cd /usr/src/app/web && yarn --silent

# Start app
WORKDIR /usr/src/app/web
CMD ["yarn", "start"]
RUN apt-get update \
&& apt-get install -y git libtool pkg-config libssl-dev build-essential python-dev automake autoconf \
&& cd /tmp \
&& git clone https://github.com/facebook/watchman.git \
&& cd watchman \
&& git checkout v4.9.0 \
&& ./autogen.sh \
&& ./configure --enable-statedir=/tmp \
&& make \
&& make install \
&& mv watchman /usr/local/bin/watchman

VOLUME /usr/src/app

WORKDIR /usr/src/app

CMD cd web && yarn start

# Core
FROM golang:1.11-alpine as core

RUN apk --no-cache --update add nodejs-npm make gcc g++ musl-dev openssl-dev git

ENV GO111MODULE=on GOPROXY=http://goproxy.berty.io:3000

VOLUME /go/src

CMD cd /go/src/berty.tech/core \
&& make dev RUN_DAEMON_OPTS="--log-level=debug --jaeger-address=react-native_tracer-service_1:6831"


Expand Up @@ -190,7 +190,7 @@ const Item = fragments.Contact(
class Received extends PureComponent {
render () {
const { navigation, screenProps } = this.props
const { queries } = screenProps.context
const { queries, subscriptions } = screenProps.context
return (
<Screen style={[{ backgroundColor: colors.white }]}>
<Pagination
Expand All @@ -202,6 +202,10 @@ class Received extends PureComponent {
])}
fragment={fragments.ContactList}
alias='ContactList'
subscriptions={[
subscriptions.contactRequest,
subscriptions.contactRequestAccepted,
]}
renderItem={props => (
<Item
{...props}
Expand All @@ -218,7 +222,7 @@ class Received extends PureComponent {
class Sent extends PureComponent {
render () {
const { navigation, screenProps } = this.props
const { queries } = screenProps.context
const { queries, subscriptions } = screenProps.context
return (
<Screen style={[{ backgroundColor: colors.white }]}>
<Pagination
Expand All @@ -230,6 +234,10 @@ class Sent extends PureComponent {
])}
fragment={fragments.ContactList}
alias='ContactList'
subscriptions={[
subscriptions.contactRequest,
subscriptions.contactRequestAccepted,
]}
renderItem={props => (
<Item
{...props}
Expand Down
24 changes: 5 additions & 19 deletions client/react-native/common/graphql/queries/Contact.js
@@ -1,32 +1,18 @@
import { fetchQuery, graphql } from 'react-relay'

import { contact } from '../../utils'
import { merge } from '../../helpers'

const query = graphql`
query ContactQuery($filter: BertyEntityContactInput) {
ContactList(
filter: $filter
first: 1
after: ""
orderBy: ""
orderDesc: false
) {
edges {
node {
...Contact
}
}
query ContactQuery($filter: BertyEntityContact) {
Contact(filter: $filter) {
id
...Contact
}
}
`

const defaultVariables = {
filter: contact.default,
orderBy: '',
orderDesc: false,
count: 1,
cursor: '',
}

export default context => ({
Expand All @@ -37,5 +23,5 @@ export default context => ({
context.environment,
query,
merge([defaultVariables, variables])
)).ContactList,
)).Contact,
})
19 changes: 12 additions & 7 deletions client/react-native/docker-compose.yml
@@ -1,13 +1,15 @@
version: '3'
version: '3.4'

services:
web-service:
build: .
image: bertychat/web
build:
context: .
target: web
image: bertychat/dev-web
ports:
- "3001:3000"
volumes:
- ./common:/usr/src/app/common
- .:/usr/src/app

tracer-service:
image: jaegertracing/all-in-one:1.6
Expand All @@ -23,12 +25,15 @@ services:
- "9411:9411"

core-service:
build: ../..
image: bertychat/berty
build:
context: .
target: core
image: bertychat/dev-core
ports:
- "8701-8801:8700"
- "1338-1438:1337"
depends_on:
- web-service
- tracer-service
command: daemon --log-level=debug --jaeger-address=react-native_tracer-service_1:6831
volumes:
- $GOPATH/src:/go/src
2 changes: 1 addition & 1 deletion core/api/node/graphql/models/scalar.go
Expand Up @@ -73,7 +73,7 @@ func UnmarshalString(v interface{}) (string, error) {

func MarshalTime(t time.Time) graphql.Marshaler {
return graphql.WriterFunc(func(w io.Writer) {
io.WriteString(w, strconv.Quote(t.String()))
io.WriteString(w, strconv.Quote(t.Format(time.RFC3339Nano)))
})
}

Expand Down
7 changes: 5 additions & 2 deletions core/api/node/graphql/resolver.go
Expand Up @@ -456,8 +456,11 @@ func (r *queryResolver) ContactList(ctx context.Context, filter *entity.Contact,
output.PageInfo.HasNextPage = hasNextPage
return output, nil
}
func (r *queryResolver) GetContact(ctx context.Context, id string) (*entity.Contact, error) {
return r.client.GetContact(ctx, &gql.Node{ID: strings.SplitN(id, ":", 2)[1]})
func (r *queryResolver) Contact(ctx context.Context, filter *entity.Contact) (*entity.Contact, error) {
if filter.ID != "" {
filter.ID = strings.SplitN(filter.ID, ":", 2)[1]
}
return r.client.Contact(ctx, &node.ContactInput{Filter: filter})
}
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) {
if filter != nil && filter.ID != "" {
Expand Down
5 changes: 4 additions & 1 deletion core/api/node/service.proto
Expand Up @@ -64,7 +64,7 @@ service Service {
option (gql.graphql_output) = ".berty.node.ContactListConnection";
option (gql.graphql_type) = "Query";
};
rpc GetContact (gql.Node) returns (berty.entity.Contact) {
rpc Contact (ContactInput) returns (berty.entity.Contact) {
option (gql.graphql_type) = "Query";
};

Expand Down Expand Up @@ -241,6 +241,9 @@ message ContactListConnection {
repeated ContactEdge edges = 1;
PageInfo page_info = 99 [(gql.graphql_non_nullable) = true];
}
message ContactInput {
berty.entity.Contact filter = 1;
}


//
Expand Down
8 changes: 4 additions & 4 deletions core/node/nodeapi.go
Expand Up @@ -329,20 +329,20 @@ func (n *Node) ContactList(input *node.ContactListInput, stream node.Service_Con
return nil
}

// GetContact implements berty.node.GetContact
func (n *Node) GetContact(ctx context.Context, input *gql.Node) (*entity.Contact, error) {
// Contact implements berty.node.Contact
func (n *Node) Contact(ctx context.Context, input *node.ContactInput) (*entity.Contact, error) {
var span opentracing.Span
span, ctx = tracing.EnterFunc(ctx, input)
defer span.Finish()
n.handleMutex(ctx)()

sql := n.sql(ctx)
contact := &entity.Contact{}
if err := sql.Where(input).First(contact).Error; err != nil {
if err := sql.Where(input).First(input).Error; err != nil {
return nil, errorcodes.ErrDb.Wrap(err)
}

return contact, nil
return input, nil
}

//
Expand Down

0 comments on commit 2b70efe

Please sign in to comment.