@eohjsc/react-native-smart-city 0.3.11 → 0.3.12

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/index.js CHANGED
@@ -17,6 +17,7 @@ import NotificationStack from './src/navigations/NotificationStack';
17
17
  import MyPinnedSharedUnit from './src/commons/Dashboard/MyPinnedSharedUnit';
18
18
  import MyUnit from './src/commons/Dashboard/MyUnit';
19
19
  import SharedUnit from './src/commons/Unit/SharedUnit';
20
+ import { Action } from './src/context/actionType';
20
21
 
21
22
  export {
22
23
  AddSubUnitStack,
@@ -40,4 +41,5 @@ export {
40
41
  SharedUnit,
41
42
  MyUnit,
42
43
  SCWrapper,
44
+ Action,
43
45
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@eohjsc/react-native-smart-city",
3
3
  "title": "React Native Smart Home",
4
- "version": "0.3.11",
4
+ "version": "0.3.12",
5
5
  "description": "TODO",
6
6
  "main": "index.js",
7
7
  "files": [
@@ -234,7 +234,7 @@ const HistoryChart = memo(
234
234
  )}
235
235
  <DateTimePickerModal
236
236
  isVisible={eventPicker.showModalStart}
237
- date={eventPicker.startTime.valueOf()}
237
+ date={eventPicker.startTime?._d}
238
238
  mode={formatType || 'datetime'}
239
239
  onConfirm={onConfirmStart}
240
240
  onCancel={onCancel}
@@ -244,7 +244,7 @@ const HistoryChart = memo(
244
244
  />
245
245
  <DateTimePickerModal
246
246
  isVisible={eventPicker.showModalEnd}
247
- date={eventPicker.endTime.valueOf()}
247
+ date={eventPicker.endTime?._d}
248
248
  mode={formatType || 'datetime'}
249
249
  onConfirm={onConfirmEnd}
250
250
  onCancel={onCancel}
@@ -112,7 +112,7 @@ export class SCConfig {
112
112
 
113
113
  export const initSCConfig = (config) => {
114
114
  api.setBaseURL(config.apiRoot ?? SCDefaultConfig.apiRoot);
115
- LocaleConfig.defaultLocale = config.language;
115
+ LocaleConfig.defaultLocale = config.language ?? SCConfig.language;
116
116
  SCConfig.language = config.language ?? SCConfig.language;
117
117
  SCConfig.apiRoot = config.apiRoot ?? SCDefaultConfig.apiRoot;
118
118
  SCConfig.GOOGLE_MAP_API_KEY =
@@ -21,6 +21,7 @@ export const Action = {
21
21
  SET_GOOGLE_HOME_CONNECTIONS: 'SET_GOOGLE_HOME_CONNECTIONS',
22
22
  CHANGE_GOOGLE_HOME_CONN_STATE: 'CHANGE_GOOGLE_HOME_CONN_STATE',
23
23
  UPDATE_VALUE_EVALUATIONS: 'UPDATE_VALUE_EVALUATIONS',
24
+ ON_RECEIVE_NOTIFICATION: 'ON_RECEIVE_NOTIFICATION',
24
25
  };
25
26
 
26
27
  export type AuthData = {
@@ -77,6 +78,7 @@ export type AppType = {
77
78
  isBluetoothEnabled: boolean;
78
79
  isNetworkConnected: boolean;
79
80
  camera_opened: any[];
81
+ notificationData: any;
80
82
  };
81
83
 
82
84
  export type IoTType = {
@@ -59,6 +59,7 @@ export const initialState = {
59
59
  isBluetoothEnabled: false,
60
60
  isNetworkConnected: false,
61
61
  camera_opened: [],
62
+ notificationData: null,
62
63
  },
63
64
  iot: {
64
65
  googlehome: {
@@ -318,6 +319,15 @@ export const reducer = (currentState: ContextData, action: Action) => {
318
319
  ),
319
320
  };
320
321
 
322
+ case Action.ON_RECEIVE_NOTIFICATION:
323
+ return {
324
+ ...currentState,
325
+ app: {
326
+ ...currentState.app,
327
+ notificationData: payload,
328
+ },
329
+ };
330
+
321
331
  default:
322
332
  return currentState;
323
333
  }
@@ -1,26 +1,20 @@
1
- import { useEffect, useState, useCallback } from 'react';
2
- import OneSignal from 'react-native-onesignal';
1
+ import { useEffect, useState } from 'react';
2
+ import { useSCContextSelector } from '../context';
3
3
 
4
4
  const useReceiveNotifications = (callBack) => {
5
- const [dataNofitication, setDataNofitication] = useState(null);
6
-
7
- const onReceived = useCallback((data) => {
8
- const { additionalData } = data;
9
- setDataNofitication(additionalData);
10
- }, []);
5
+ const [dataNotification, setDataNotification] = useState(null);
6
+ const notificationData = useSCContextSelector(
7
+ (state) => state.app.notificationData
8
+ );
11
9
 
12
10
  useEffect(() => {
13
- OneSignal.setNotificationWillShowInForegroundHandler(
14
- (notifReceivedEvent) => {
15
- let notif = notifReceivedEvent.getNotification();
16
- setTimeout(() => notifReceivedEvent.complete(notif), 0);
17
- onReceived(notif);
18
- callBack && callBack();
19
- }
20
- );
21
- }, [callBack, onReceived]);
11
+ if (notificationData) {
12
+ setDataNotification(notificationData);
13
+ callBack && callBack();
14
+ }
15
+ }, [callBack, notificationData]);
22
16
 
23
- return { dataNofitication };
17
+ return { dataNotification };
24
18
  };
25
19
 
26
20
  export default useReceiveNotifications;
@@ -189,7 +189,7 @@ const UnitDetail = ({ route }) => {
189
189
  });
190
190
 
191
191
  return () => {
192
- subscription.remove();
192
+ subscription?.remove();
193
193
  };
194
194
  }, [fetchDetails]);
195
195
 
@@ -69,7 +69,7 @@ const Summaries = memo(({ unit }) => {
69
69
  });
70
70
 
71
71
  return () => {
72
- subscription.remove();
72
+ subscription?.remove();
73
73
  };
74
74
  }, [fetchUnitSummary]);
75
75