ordering-ui-react-native 0.14.63 → 0.14.64

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ordering-ui-react-native",
3
- "version": "0.14.63",
3
+ "version": "0.14.64",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -1,4 +1,4 @@
1
- import React, { useEffect, useState } from 'react';
1
+ import React, { useCallback, useEffect, useRef, useState } from 'react';
2
2
  import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
3
3
  import Geolocation from '@react-native-community/geolocation'
4
4
  import {
@@ -44,7 +44,7 @@ import { BusinessFeaturedController } from '../BusinessFeaturedController';
44
44
  import { HighestRatedBusinesses } from '../HighestRatedBusinesses';
45
45
  import { getTypesText, convertToRadian } from '../../utils';
46
46
  import { OrderProgress } from '../OrderProgress';
47
- import { useIsFocused } from '@react-navigation/native';
47
+ import { useFocusEffect, useIsFocused } from '@react-navigation/native';
48
48
 
49
49
  const PIXELS_TO_SCROLL = 1000;
50
50
 
@@ -115,15 +115,15 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
115
115
  const [featuredBusiness, setFeaturedBusinesses] = useState(Array);
116
116
  const [isFarAway, setIsFarAway] = useState(false)
117
117
 
118
- // const timerId = useRef<any>(false)
118
+ const timerId = useRef<any>(false)
119
119
  // const panResponder = useRef(
120
- // PanResponder.create({
121
- // onMoveShouldSetPanResponder: (e, gestureState) => {
122
- // const {dx, dy} = gestureState;
123
- // resetInactivityTimeout()
124
- // return (Math.abs(dx) > 20) || (Math.abs(dy) > 20);
125
- // },
126
- // })
120
+ // PanResponder.create({
121
+ // onMoveShouldSetPanResponder: (e, gestureState) => {
122
+ // const { dx, dy } = gestureState;
123
+ // resetInactivityTimeout()
124
+ // return (Math.abs(dx) > 20) || (Math.abs(dy) > 20);
125
+ // },
126
+ // })
127
127
  // ).current
128
128
 
129
129
  const configTypes =
@@ -165,16 +165,18 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
165
165
  }
166
166
  }, [businessesList.businesses]);
167
167
 
168
- // const resetInactivityTimeout = () => {
169
- // clearTimeout(timerId.current)
170
- // timerId.current = setInterval(() => {
171
- // getBusinesses(true)
172
- // }, 600000)
173
- // }
168
+ const resetInactivityTimeout = () => {
169
+ clearTimeout(timerId.current)
170
+ timerId.current = setInterval(() => {
171
+ if (!businessesList.loading) {
172
+ getBusinesses(true)
173
+ }
174
+ }, 300000)
175
+ }
174
176
 
175
- // useEffect(() => {
176
- // resetInactivityTimeout()
177
- // }, [])
177
+ useEffect(() => {
178
+ resetInactivityTimeout()
179
+ }, [])
178
180
 
179
181
  const handleOnRefresh = () => {
180
182
  if (!businessesList.loading) {
@@ -195,6 +197,14 @@ const BusinessesListingUI = (props: BusinessesListingParams) => {
195
197
  })
196
198
  }, [orderState?.options?.address?.location])
197
199
 
200
+ useFocusEffect(
201
+ useCallback(() => {
202
+ getBusinesses(true)
203
+ resetInactivityTimeout()
204
+ return () => clearTimeout(timerId.current)
205
+ }, [navigation])
206
+ )
207
+
198
208
  return (
199
209
  <ScrollView style={styles.container} onScroll={(e) => handleScroll(e)} showsVerticalScrollIndicator={false}
200
210
  refreshControl={
@@ -277,7 +277,7 @@ const MomentOptionUI = (props: MomentOptionParams) => {
277
277
  style={{ marginEnd: 24 }}
278
278
  />
279
279
  )}
280
- <OText color={optionSelected.isAsap ? theme.colors.textNormal : theme.colors.disabled}>{t('ASAP_ABBREVIATION', 'ASAP') + ` (${moment().format('dddd, MMM d, yyyy h:mm A')} + delivery time)`}</OText>
280
+ <OText color={optionSelected.isAsap ? theme.colors.textNormal : theme.colors.disabled}>{t('ASAP_ABBREVIATION', 'ASAP') + ` (${moment().format('dddd, MMM D, yyyy h:mm A')} + delivery time)`}</OText>
281
281
  </WrapSelectOption>
282
282
  <WrapSelectOption
283
283
  onPress={() => setOptionSelected({ isAsap: false, isSchedule: true })}