This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { gql } from '@apollo/client'; | |
| export const RegisterDeviceMutation = gql` | |
| mutation RegisterDevice($input: DeviceRegisterInput!) { | |
| device { | |
| register(input: $input) | |
| } | |
| } | |
| `; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [...] | |
| const MessagesMutation: MessagesMutationResolvers = { | |
| async send(_, { input }) { | |
| const message = new MessageModel(input); | |
| await message.save(); | |
| pubsub.publish(NEW_MESSAGE_EVENT, { message }); | |
| sendPushNotification({ | |
| title: input.senderName, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Expo, { ExpoPushMessage } from 'expo-server-sdk'; | |
| import DeviceTokenModel from '../models/DeviceTokenModel'; | |
| const expo = new Expo(); | |
| interface SendPushNotificationArgs { | |
| user_id?: string; | |
| title: string; | |
| body: string; | |
| payload?: { [key: string]: any }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { makeExecutableSchema } from 'graphql-tools'; | |
| import merge = require('lodash/merge'); | |
| import Scalars from './scalars'; | |
| // Modules | |
| import Messages from './resolvers/Messages'; | |
| import Device from './resolvers/Device'; | |
| const Modules = { | |
| typeDefs: [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { gql } from 'apollo-server-express'; | |
| import { DeviceMutationResolvers } from '../generated/graphql'; | |
| import DeviceTokenModel from '../models/DeviceTokenModel'; | |
| const typeDefs = gql` | |
| enum DevicePlatform { | |
| IOS | |
| ANDROID | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as mongoose from 'mongoose'; | |
| export interface DeviceTokenDocument extends mongoose.Document { | |
| user_id: string; | |
| token: string; | |
| devicePlatform?: string; | |
| deviceYear?: string; | |
| systemVersion?: string; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as React from 'react'; | |
| import { FlatListProps, FlatList, Keyboard, PanResponderGestureState, PanResponder } from 'react-native'; | |
| export const MessageListMobile = <T extends {}>(props: FlatListProps<T> & { innerRef?: React.RefObject<FlatList<T>> }) => { | |
| const keyboardPosY = React.useRef(0); | |
| const isVisibleKeyboard = React.useRef(false); | |
| const accessoryViewHeight = 53 / 2; | |
| React.useEffect(() => { | |
| const keyboardDidShowListener = Keyboard.addListener( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react'; | |
| import { Keyboard } from 'react-native'; | |
| export const useKeyboard = (): [boolean, () => void] => { | |
| const [visible, setVisible] = React.useState(false); | |
| const dismiss = () => { | |
| Keyboard.dismiss(); | |
| setVisible(false); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Dimensions, Platform } from "react-native"; | |
| const width = Dimensions.get("window").width; | |
| const height = Dimensions.get("window").height; | |
| export const isIphoneX = | |
| Platform.OS === "ios" && | |
| !Platform.isPad && | |
| !Platform.isTVOS && | |
| (height === 812 || width === 812 || height === 896 || width === 896); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react' | |
| import { View, ActivityIndicator, TextInput, StyleSheet, Platform, TouchableOpacity, FlatList } from 'react-native'; | |
| import { KeyboardAccessoryView } from 'react-native-keyboard-accessory'; | |
| import { Ionicons } from '@expo/vector-icons'; | |
| import { MainNavProps } from '../navigation/types/MainStackParams'; | |
| import { AuthContext } from '../contexts/AuthContext'; | |
| import { useMessages, useSendMessage } from '../graphql/cache/Messages'; | |
| import { MessageItem } from '../components/Items/MessageItem'; | |
| import { Button } from '../components/Button'; | |
| import { isIphoneX } from '../utils'; |