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'; | |
import { MessageItemFragment } from '../../components/Items/MessageItem'; | |
export const GetMessagesQuery = gql` | |
query Messages($offset: Int!) { | |
messages(offset: $offset, limit: 20) { | |
...MessageItem | |
} | |
} |
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 } from 'react-native'; | |
import { AuthNavProps } from '../navigation/types/AuthStackParams'; | |
import { Input } from '../components/Input'; | |
import { Button } from '../components/Button'; | |
import { AuthContext } from '../contexts/AuthContext'; | |
export const LoginScreen = ({}: AuthNavProps<'Login'>) => { | |
const [name, setName] = React.useState(''); | |
const { login } = React.useContext(AuthContext); |
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 UUID from 'uuid-random'; | |
import { useMessagesQuery, MessageSubscription as MessageSubscriptionType, useSendMessageMutation, MessageSendInput, SendMessageMutation, MessagesQuery } from '../generated'; | |
import { MessageSubscription, GetMessagesQuery } from '../queries/Messages'; | |
export const useMessages = ({ sender_id }: { sender_id: string }) => { | |
const [isStopFetchMore, setStopFetchMore] = React.useState(false); | |
const { data, fetchMore: fetchMoreMessages, loading, subscribeToMore, ...other } = useMessagesQuery({ | |
fetchPolicy: 'cache-and-network', | |
variables: { offset: 0 }, |
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, StyleSheet, Text } from 'react-native'; | |
import moment from 'moment'; | |
import { gql } from '@apollo/client'; | |
import * as Types from '../../graphql/generated'; | |
export const TIME_FORMAT = 'HH:mm'; | |
export const MessageItemFragment = gql` | |
fragment MessageItem on Message { |
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'; |
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 { 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 * 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 * 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 { gql } from 'apollo-server-express'; | |
import { DeviceMutationResolvers } from '../generated/graphql'; | |
import DeviceTokenModel from '../models/DeviceTokenModel'; | |
const typeDefs = gql` | |
enum DevicePlatform { | |
IOS | |
ANDROID | |
} |