ordering-ui-react-native 0.24.0 → 0.24.1
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
|
@@ -4,10 +4,7 @@ import {
|
|
|
4
4
|
View,
|
|
5
5
|
StyleSheet,
|
|
6
6
|
Dimensions,
|
|
7
|
-
TouchableOpacity
|
|
8
|
-
NativeModules,
|
|
9
|
-
PermissionsAndroid,
|
|
10
|
-
Platform
|
|
7
|
+
TouchableOpacity
|
|
11
8
|
} from 'react-native';
|
|
12
9
|
import { useTheme } from 'styled-components/native'
|
|
13
10
|
import moment from 'moment'
|
|
@@ -20,7 +17,6 @@ import {
|
|
|
20
17
|
useEvent,
|
|
21
18
|
useLanguage,
|
|
22
19
|
useSession,
|
|
23
|
-
useConfig,
|
|
24
20
|
useToast,
|
|
25
21
|
ToastType
|
|
26
22
|
} from 'ordering-components/native'
|
|
@@ -36,48 +32,25 @@ const SoundPlayerComponent = (props: any) => {
|
|
|
36
32
|
const { evtList, currentEvent, handleCloseEvents } = props
|
|
37
33
|
|
|
38
34
|
const theme = useTheme()
|
|
39
|
-
const
|
|
40
|
-
const [isEnabledReadStorage, setIsEnabledReadStorage] = useState(true)
|
|
41
|
-
const URL_SOUND = 'https://d33aymufw4jvwf.cloudfront.net/notification.mp3' ?? theme.sounds.notification
|
|
35
|
+
const URL_SOUND = 'https://d33aymufw4jvwf.cloudfront.net/notification.mp3'
|
|
42
36
|
|
|
43
37
|
useEffect(() => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const playSound = async () => {
|
|
38
|
+
if (!currentEvent?.orderId) return
|
|
39
|
+
const playSound = () => {
|
|
47
40
|
try {
|
|
48
41
|
SoundPlayer.playUrl(URL_SOUND)
|
|
49
|
-
|
|
50
|
-
SoundPlayer.stop()
|
|
51
|
-
} catch (err: any) {
|
|
42
|
+
} catch (e) {
|
|
52
43
|
console.log('Sound Error - ', err.message)
|
|
53
44
|
}
|
|
54
45
|
}
|
|
55
|
-
if (NativeModules?.RNSoundPlayer?.playUrl && typeof URL_SOUND === 'string' && isEnabledReadStorage) {
|
|
56
|
-
playSound()
|
|
57
|
-
}
|
|
58
46
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
SoundPlayer.stop()
|
|
63
|
-
} catch (err: any) {
|
|
64
|
-
console.log('Sound Error - ', err.message)
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}, [count, isEnabledReadStorage])
|
|
47
|
+
const interval = setInterval(() => {
|
|
48
|
+
playSound()
|
|
49
|
+
}, DELAY_SOUND)
|
|
68
50
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if (Platform.OS === 'android') {
|
|
72
|
-
const enabled = await PermissionsAndroid.check(PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE)
|
|
73
|
-
setIsEnabledReadStorage(enabled)
|
|
74
|
-
} else {
|
|
75
|
-
setIsEnabledReadStorage(true)
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
// checkSoundMedia()
|
|
51
|
+
return () => clearInterval(interval)
|
|
52
|
+
}, [currentEvent?.orderId])
|
|
79
53
|
|
|
80
|
-
}, [])
|
|
81
54
|
return (
|
|
82
55
|
<Modal
|
|
83
56
|
animationType='slide'
|
|
@@ -129,7 +102,7 @@ const NewOrderNotificationUI = (props: any) => {
|
|
|
129
102
|
const handleEventNotification = async (evtType: number, value: any, orderStatus?: any) => {
|
|
130
103
|
if (value?.driver) {
|
|
131
104
|
try {
|
|
132
|
-
const location = await getCurrentLocation()
|
|
105
|
+
const location: any = await getCurrentLocation()
|
|
133
106
|
if (!location?.latitude || !location?.longitude) {
|
|
134
107
|
showToast(t('ERROR_UPDATING_COORDS', 'Error updating coords'), ToastType.Error)
|
|
135
108
|
return
|
|
@@ -154,18 +127,18 @@ const NewOrderNotificationUI = (props: any) => {
|
|
|
154
127
|
const duration = moment.duration(moment().diff(moment.utc(value?.last_driver_assigned_at)))
|
|
155
128
|
const assignedSecondsDiff = duration.asSeconds()
|
|
156
129
|
if (assignedSecondsDiff < 5 && !isBusinessApp && !value?.logistic_status) {
|
|
157
|
-
setCurrentEvent({ evt: 2, orderId: value?.id ?? value?.order_id })
|
|
130
|
+
setCurrentEvent(() => ({ evt: 2, orderId: value?.id ?? value?.order_id }))
|
|
158
131
|
}
|
|
159
132
|
}
|
|
160
133
|
if ((!orderStatus.includes(value.status) && evtType !== 1 && isBusinessApp && orderStatus?.length > 0) || value?.author_id === user.id) return
|
|
161
|
-
setCurrentEvent({
|
|
134
|
+
setCurrentEvent(() => ({
|
|
162
135
|
evt: evtType,
|
|
163
136
|
orderId: value?.driver
|
|
164
137
|
? value?.order_id ?? value?.id
|
|
165
138
|
: evtList(currentEvent)[evtType].event === 'messages'
|
|
166
139
|
? value?.order?.id
|
|
167
140
|
: value?.order_id ?? value?.id
|
|
168
|
-
})
|
|
141
|
+
}))
|
|
169
142
|
}
|
|
170
143
|
|
|
171
144
|
useEffect(() => {
|