update whatsapp clone sample app (#1822)

This commit is contained in:
Praveen Durairaj 2019-03-20 15:03:04 +05:30 committed by Shahidh K Muhammed
parent 42b1d16625
commit 2ee9820c22
14 changed files with 61 additions and 27 deletions

View File

@ -0,0 +1 @@
node_modules

View File

@ -1,3 +1,4 @@
node_modules
npm-debug.log
.env
build

View File

@ -0,0 +1,21 @@
FROM node:carbon
# Create app directory
WORKDIR /app
# Install app dependencies
RUN npm -g install serve
# A wildcard is used to ensure both package.json AND package-lock.json are copied
COPY package*.json ./
RUN npm install
# Bundle app source
COPY . /app
#Build react/vue/angular bundle static files
#RUN npm run generate
RUN npm run build
EXPOSE 8080
# serve build folder on port 8080
CMD ["serve", "-s", "build", "-p", "8080"]

View File

@ -12,7 +12,7 @@ Run codegen to generate TypeScript types
yarn generate
**Note**: The types are generated from the server! So if you have `admin secret` enabled in your graphql-engine server, make sure to update the headers in `codegen.yml` file.
**Note**: The types are generated from the server! So if you have `admin secret` enabled in your graphql-engine server, make sure to update the headers in `codegen.js` file.
Set environment variables. Open `.env` file and add the following env

View File

@ -0,0 +1,24 @@
module.exports = {
"schema": [
{
"http://localhost:8080/v1alpha1/graphql": {
"headers": {
"x-hasura-admin-secret": ""
}
}
}
],
"documents": [
"./src/**/*.tsx",
"./src/**/*.ts"
],
"overwrite": true,
"generates": {
"./src/graphql/types.ts": {
"plugins": [
"typescript-common",
"typescript-client"
]
}
}
};

View File

@ -1,13 +0,0 @@
schema:
- http://localhost:8080/v1alpha1/graphql:
#headers:
# x-hasura-admin-secret:
documents:
- ./src/**/*.tsx
- ./src/**/*.ts
overwrite: true
generates:
./src/graphql/types.ts:
plugins:
- typescript-common
- typescript-client

View File

@ -46,7 +46,7 @@
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"generate": "gql-gen",
"generate": "gql-gen --config codegen.js",
"generate:watch": "nodemon --exec yarn generate -e graphql"
},
"eslintConfig": {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.png" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"

View File

@ -1,9 +1,9 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"short_name": "WhatsApp Clone",
"name": "WhatsApp Clone",
"icons": [
{
"src": "favicon.ico",
"src": "favicon.png",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
}

View File

@ -15,7 +15,7 @@ import styled from 'styled-components'
import * as fragments from '../../graphql/fragments'
import * as queries from '../../graphql/queries'
import { useMe } from '../../services/auth.service';
import { ChatList, DeleteChat, ChatsListQueryCache } from '../../graphql/types'
import { ChatList, DeleteChat, ChatsListCacheQuery } from '../../graphql/types'
const Style = styled.div`
padding: 0;
@ -76,7 +76,7 @@ const query = gql`
`
const queryCache = gql`
query ChatsListQueryCache($userId: Int!) {
query ChatsListCacheQuery($userId: Int!) {
chat(order_by:[{messages_aggregate:{max:{created_at:desc}}}]) {
...chat
users(where:{user_id:{_neq:$userId}}) {
@ -125,7 +125,7 @@ export default ({ chatId, history }: ChatNavbarProps) => {
update: (client, { data: { delete_chat } }) => {
let chats
try {
chats = client.readQuery<ChatsListQueryCache.Query, ChatsListQueryCache.Variables>({
chats = client.readQuery<ChatsListCacheQuery.Query, ChatsListCacheQuery.Variables>({
query: queryCache,
variables: {userId: me.id}
}).chat
@ -136,7 +136,7 @@ export default ({ chatId, history }: ChatNavbarProps) => {
// filter current parsedChatId
chats = chats.filter((chat) => chat.id !== parsedChatId);
try {
client.writeQuery<ChatsListQueryCache.Query, ChatsListQueryCache.Variables>({
client.writeQuery<ChatsListCacheQuery.Query, ChatsListCacheQuery.Variables>({
query: queryCache,
variables: {userId: me.id},
data: { chat: chats },

View File

@ -199,9 +199,9 @@ export default ({ location, match, history }: RouteComponentProps) => {
if (!file) return
const { url } = await uploadProfilePicture(file)
const { secure_url } = await uploadProfilePicture(file)
setChatPicture(url)
setChatPicture(secure_url)
}
return (

View File

@ -105,9 +105,9 @@ export default ({ history }: RouteComponentProps) => {
if (!file) return
const { url } = await uploadProfilePicture(file)
const { secure_url } = await uploadProfilePicture(file)
setMyPicture(url)
setMyPicture(secure_url)
}
return (