@eohjsc/react-native-smart-city 0.4.53 → 0.4.54

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/README.md CHANGED
@@ -35,12 +35,35 @@ import {
35
35
  AutomateStack,
36
36
  NotificationStack,
37
37
  } from '@eohjsc/react-native-smart-city';
38
+ import Config from 'react-native-config';
38
39
  import { createStackNavigator } from '@react-navigation/stack';
39
40
 
40
41
  // TODO: What to do with the module?
41
42
  const Stack = createStackNavigator();
42
43
 
43
44
  const YourStack = () => {
45
+
46
+
47
+ useEffect(() => {
48
+ const config = {
49
+ apiRoot: Config.API_ROOT,
50
+ GOOGLE_MAP_API_KEY: Config.GOOGLE_MAP_API_KEY,
51
+ LG_CLIENT_ID: Config.LG_CLIENT_ID,
52
+ LG_REDIRECT_URI_APP: Config.LG_REDIRECT_URI_APP,
53
+ LG_URL: Config.LG_URL,
54
+ VCONNEX_CLIENT_ID: Config.VCONNEX_CLIENT_ID,
55
+ VCONNEX_REDIRECT_URI_APP: Config.VCONNEX_REDIRECT_URI,
56
+ pusherAppKey: Config.PUSHER_APP_KEY,
57
+ pusherAppCluster: Config.PUSHER_APP_CLUSTER,
58
+ language,
59
+ setCurrentSensorDisplay,
60
+ appName: Config.APP_NAME,
61
+ packageName: Config.APP_PACKAGE_NAME, // Your package name is required
62
+ versionCode: Config.APP_VERSION_CODE, // Your app version is required
63
+ };
64
+ initSCConfig(config);
65
+ }, [language, setCurrentSensorDisplay]);
66
+
44
67
  // Declare yourAuthObject and params
45
68
  return (
46
69
  <Stack.Navigator>
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.4.53",
4
+ "version": "0.4.54",
5
5
  "description": "TODO",
6
6
  "main": "index.js",
7
7
  "files": [
@@ -8,6 +8,16 @@ import IconComponent from '../IconComponent';
8
8
 
9
9
  const ItemQuickAction = memo(
10
10
  ({ sensor, wrapperStyle, setStatus, iconSize = 30 }) => {
11
+ const { quick_action } = sensor || {};
12
+ const {
13
+ config_id,
14
+ off_action,
15
+ on_status,
16
+ on_action,
17
+ off_status,
18
+ interval,
19
+ will_auto_update_status,
20
+ } = quick_action || {};
11
21
  const [action, setAction] = useState(sensor.action);
12
22
  // eslint-disable-next-line no-unused-vars
13
23
  const [configValues, _] = useConfigGlobalState('configValues');
@@ -17,26 +27,34 @@ const ItemQuickAction = memo(
17
27
  const [processing, setProcessing] = useState(false);
18
28
 
19
29
  useEffect(() => {
20
- if (!(sensor.quick_action?.config_id in configValues)) {
30
+ if (!(config_id in configValues)) {
21
31
  return;
22
32
  }
23
- const configValue = configValues[sensor.quick_action.config_id];
33
+ const configValue = configValues[config_id];
24
34
  setIsOn(configValue?.value);
25
- }, [sensor, configValues]);
35
+ }, [configValues, config_id]);
26
36
 
27
37
  useEffect(() => {
28
- if (!sensor.quick_action) {
38
+ if (!quick_action) {
29
39
  return;
30
40
  }
31
41
 
32
42
  if (isOn) {
33
- setAction(sensor.quick_action.off_action);
34
- setStatus && setStatus(sensor.quick_action.on_status);
43
+ setAction(off_action);
44
+ setStatus && setStatus(on_status);
35
45
  } else {
36
- setAction(sensor.quick_action.on_action);
37
- setStatus && setStatus(sensor.quick_action.off_status);
46
+ setAction(on_action);
47
+ setStatus && setStatus(off_status);
38
48
  }
39
- }, [isOn, setStatus, sensor.quick_action]);
49
+ }, [
50
+ isOn,
51
+ setStatus,
52
+ quick_action,
53
+ off_action,
54
+ on_status,
55
+ on_action,
56
+ off_status,
57
+ ]);
40
58
 
41
59
  const userId = useSCContextSelector((state) => state?.auth.account.user.id);
42
60
  const onActionPress = useCallback(async () => {
@@ -46,9 +64,7 @@ const ItemQuickAction = memo(
46
64
  }
47
65
  setProcessing(true);
48
66
  let data = null;
49
- if (
50
- action?.allow_config_store_value_id === sensor?.quick_action?.config_id
51
- ) {
67
+ if (action?.allow_config_store_value_id === config_id) {
52
68
  if (action?.name?.toLowerCase().includes('off')) {
53
69
  data = {
54
70
  config_id: action?.allow_config_store_value_id,
@@ -64,13 +80,23 @@ const ItemQuickAction = memo(
64
80
  }
65
81
  await sendRemoteCommand(sensor, action, data, userId);
66
82
 
67
- if (!sensor.quick_action.will_auto_update_status) {
83
+ if (!will_auto_update_status) {
68
84
  setTimeout(() => {
69
- setIsOn(action.id === sensor.quick_action.on_action.id);
70
- }, sensor.quick_action.interval);
85
+ setIsOn(action.id === on_action.id);
86
+ }, interval);
71
87
  }
72
88
  setProcessing(false);
73
- }, [processing, action, sensor, sendRemoteCommand, userId]);
89
+ }, [
90
+ processing,
91
+ action,
92
+ config_id,
93
+ sendRemoteCommand,
94
+ sensor,
95
+ userId,
96
+ will_auto_update_status,
97
+ interval,
98
+ on_action?.id,
99
+ ]);
74
100
 
75
101
  if (!action) {
76
102
  return <View />;
@@ -37,7 +37,7 @@ const watchingConfigs = {};
37
37
 
38
38
  export const updateGlobalValue = (configId, value) => {
39
39
  const configValues = getConfigGlobalState('configValues');
40
- const newConfigValues = { ...configValues };
40
+ let newConfigValues = { ...configValues };
41
41
  newConfigValues[configId] = value;
42
42
  setConfigGlobalState('configValues', newConfigValues);
43
43
  };