ordering-ui-react-native 0.23.95 → 0.23.96
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,4 +1,4 @@
|
|
|
1
|
-
import React, { useEffect, useMemo, useState } from 'react'
|
|
1
|
+
import React, { useEffect, useMemo, useState, useCallback } from 'react'
|
|
2
2
|
import { useLanguage, BusinessSearchList, useOrder, useUtils, useEvent, showToast, ToastType } from 'ordering-components/native'
|
|
3
3
|
import { ScrollView, StyleSheet, Dimensions, FlatList } from 'react-native'
|
|
4
4
|
import { useTheme } from 'styled-components/native'
|
|
@@ -16,7 +16,6 @@ import {
|
|
|
16
16
|
import FastImage from 'react-native-fast-image'
|
|
17
17
|
import { convertHoursToMinutes } from '../../utils'
|
|
18
18
|
import { BusinessSearchParams } from '../../types'
|
|
19
|
-
import { useIsFocused } from '@react-navigation/native';
|
|
20
19
|
|
|
21
20
|
import { BusinessSearchHeader } from './BusinessSearchHeader'
|
|
22
21
|
import { BusinessSearchFooter } from './BusinessSearchFooter'
|
|
@@ -49,8 +48,6 @@ export const BusinessListingSearchUI = (props: BusinessSearchParams) => {
|
|
|
49
48
|
|
|
50
49
|
const [openFilters, setOpenFilters] = useState(false)
|
|
51
50
|
|
|
52
|
-
const isFocused = useIsFocused();
|
|
53
|
-
|
|
54
51
|
const styles = StyleSheet.create({
|
|
55
52
|
productsContainer: {
|
|
56
53
|
marginTop: 20
|
|
@@ -130,17 +127,16 @@ export const BusinessListingSearchUI = (props: BusinessSearchParams) => {
|
|
|
130
127
|
})
|
|
131
128
|
}
|
|
132
129
|
|
|
133
|
-
const handleScroll = ({ nativeEvent }: any) => {
|
|
130
|
+
const handleScroll = useCallback(({ nativeEvent }: any) => {
|
|
134
131
|
const y = nativeEvent.contentOffset.y;
|
|
135
132
|
const height = nativeEvent.contentSize.height;
|
|
136
133
|
const hasMore = !(
|
|
137
134
|
paginationProps.totalPages === paginationProps.currentPage
|
|
138
135
|
);
|
|
139
|
-
|
|
140
|
-
if (y + PIXELS_TO_SCROLL > height && !businessesSearchList.loading && hasMore && businessesSearchList?.businesses?.length > 0) {
|
|
136
|
+
if (height > 1000 && y + PIXELS_TO_SCROLL > height && !businessesSearchList.loading && hasMore && businessesSearchList?.businesses?.length > 0) {
|
|
141
137
|
handleSearchbusinessAndProducts();
|
|
142
138
|
}
|
|
143
|
-
};
|
|
139
|
+
}, [businessesSearchList.loading, businessesSearchList?.businesses?.length]);
|
|
144
140
|
|
|
145
141
|
const onChangeTermValue = (query: any) => {
|
|
146
142
|
handleChangeTermValue(query)
|
|
@@ -159,11 +155,6 @@ export const BusinessListingSearchUI = (props: BusinessSearchParams) => {
|
|
|
159
155
|
handleSearchbusinessAndProducts(true)
|
|
160
156
|
}, [])
|
|
161
157
|
|
|
162
|
-
|
|
163
|
-
useEffect(() => {
|
|
164
|
-
handleChangeTermValue('')
|
|
165
|
-
}, [isFocused])
|
|
166
|
-
|
|
167
158
|
const businessFiltered = useMemo(() => {
|
|
168
159
|
return businessesSearchList.businesses?.filter((business: any) => business?.categories?.length > 0)
|
|
169
160
|
}, [businessesSearchList.businesses])
|