message: [Favorites] adds pagination support to Works tab
diff: import React from "react"
  import { View } from "react-native"
  -import { createPaginationContainer, graphql } from "react-relay"
  +import { createPaginationContainer, graphql, RelayPaginationProp } from "react-relay"
  import styled from "styled-components/native"
  import GenericGrid from "lib/Components/ArtworkGrids/GenericGrid"
  @@ -11,7 +11,35 @@ const Container = styled.ScrollView`
  flex: 1;
  `
  -export class SavedWorks extends React.Component<any, any> {
  +interface Props extends RelayProps {
  + relay?: RelayPaginationProp
  + onDataFetching?: (loading: boolean) => void
  +}
  +
  +export class SavedWorks extends React.Component<Props, any> {
  + loadMore() {
  + if (!this.props.relay.hasMore() || this.props.relay.isLoading()) {
  + return
  + }
  +
  + const updateState = (loading: boolean) => {
  + this.setState({ fetchingMoreData: loading })
  + if (this.props.onDataFetching) {
  + this.props.onDataFetching(loading)
  + }
  + }
  +
  + updateState(true)
  + this.props.relay.loadMore(10, e => {
  + updateState(false)
  + })
  + }
  +
  + isCloseToBottom({ layoutMeasurement, contentOffset, contentSize }) {
  + const paddingToBottom = 20
  + return layoutMeasurement.height + contentOffset.y >= contentSize.height - paddingToBottom
  + }
  +
  render() {
  const artworks = this.props.me.saved_artworks.artworks_connection.edges.map(edge => edge.node)
  @@ -23,7 +51,14 @@ export class SavedWorks extends React.Component<any, any> {
  )
  const Content = (
  - <Container>
  + <Container
  + onScroll={({ nativeEvent }) => {
  + if (this.isCloseToBottom(nativeEvent)) {
  + this.loadMore()
  + }
  + }}
  + scrollEventThrottle={400}
  + >
  <GenericGrid artworks={artworks} />
  </Container>
  )
  @@ -57,8 +92,8 @@ export default createPaginationContainer(
  },
  {
  direction: "forward",
  - getConnectionFromProps(props) {
  - return props.me && props.me.saved_artworks_connection
  + getConnectionFromProps(props: Props) {
  + return props.me && props.me.saved_artworks.artworks_connection
  },
  getFragmentVariables(prevVars, totalCount) {
  return {
  @@ -82,3 +117,15 @@ export default createPaginationContainer(
  `,
  }
  )
  +
  +interface RelayProps {
  + me: {
  + saved_artworks: {
  + artworks_connection: {
  + edges: Array<{
  + node: any | null
  + }> | null
  + } | null
  + } | null
  + } | null
  +}
  