ordering-ui-react-native 0.15.21 → 0.15.22

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.15.21",
3
+ "version": "0.15.22",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -1,5 +1,5 @@
1
- import React, { useState, useEffect } from 'react'
2
- import { View, StyleSheet, BackHandler, TouchableOpacity, I18nManager } from 'react-native'
1
+ import React, { useState, useEffect, useRef } from 'react'
2
+ import { View, StyleSheet, BackHandler, TouchableOpacity, I18nManager, AppState } from 'react-native'
3
3
  import LinearGradient from 'react-native-linear-gradient'
4
4
  import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder';
5
5
  import MaterialCommunityIcon from 'react-native-vector-icons/MaterialCommunityIcons'
@@ -64,7 +64,8 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
64
64
  isFromRoot,
65
65
  driverLocation,
66
66
  goToBusinessList,
67
- onNavigationRedirect
67
+ onNavigationRedirect,
68
+ getOrder
68
69
  } = props
69
70
 
70
71
  const theme = useTheme()
@@ -108,6 +109,8 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
108
109
  const [isReviewed, setIsReviewed] = useState(false)
109
110
  const [openOrderCreating, setOpenOrderCreating] = useState(false)
110
111
  const [openTaxModal, setOpenTaxModal] = useState<any>({ open: false, tax: null, type: '' })
112
+ const appState = useRef(AppState.currentState)
113
+
111
114
  const { order, loading, businessData, error } = props.order
112
115
 
113
116
  const getOrderStatus = (s: string) => {
@@ -256,6 +259,24 @@ export const OrderDetailsUI = (props: OrderDetailsParams) => {
256
259
  })
257
260
  }, [])
258
261
 
262
+ useEffect(() => {
263
+ const onFocusApp = (nextAppState: any) => {
264
+ if (
265
+ appState.current.match(/inactive|background/) &&
266
+ nextAppState === "active"
267
+ ) {
268
+ getOrder && getOrder()
269
+ }
270
+ appState.current = nextAppState;
271
+ }
272
+
273
+ AppState.addEventListener("change", onFocusApp);
274
+ return () => {
275
+ AppState.removeEventListener('change', onFocusApp);
276
+ };
277
+ }, [])
278
+
279
+
259
280
  return (
260
281
  <OrderDetailsContainer keyboardShouldPersistTaps='handled'>
261
282
  {order && order?.id && !error && !loading && (
@@ -287,6 +287,7 @@ export interface OrderDetailsParams {
287
287
  isFromRoot?: any;
288
288
  goToBusinessList?: any;
289
289
  onNavigationRedirect?: any;
290
+ getOrder?: () => {}
290
291
  }
291
292
  export interface ProductItemAccordionParams {
292
293
  key?: any;