@eohjsc/react-native-smart-city 0.4.98 → 0.5.0

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.
Files changed (33) hide show
  1. package/package.json +1 -1
  2. package/src/commons/ActionGroup/OnOffTemplate/index.js +3 -31
  3. package/src/commons/ActionGroup/SliderRangeTemplate.js +2 -2
  4. package/src/commons/ActionGroup/TerminalBoxTemplate.js +182 -0
  5. package/src/commons/ActionGroup/TerminalBoxTemplateStyle.js +57 -0
  6. package/src/commons/ActionGroup/TextBoxTemplate.js +29 -24
  7. package/src/commons/ActionGroup/TextBoxTemplateStyle.js +3 -0
  8. package/src/commons/ActionGroup/__test__/TerminalBoxTemplate.test.js +232 -0
  9. package/src/commons/ActionGroup/__test__/TextBoxTemplate.test.js +1 -1
  10. package/src/commons/ActionGroup/index.js +3 -1
  11. package/src/commons/Device/ConnectedViewHeader.js +1 -2
  12. package/src/commons/Device/PMSensor/PMSensorIndicator.js +3 -5
  13. package/src/commons/HeaderAni/index.js +1 -1
  14. package/src/commons/OneTapTemplate/TerminalBoxActionTemplate.js +87 -0
  15. package/src/commons/OneTapTemplate/TextBoxActionTemplate.js +2 -2
  16. package/src/commons/OneTapTemplate/__test__/TerminalBoxActionTemplate.test.js +118 -0
  17. package/src/commons/Sharing/WrapHeaderScrollable.js +1 -1
  18. package/src/commons/SubUnit/__test__/ShortDetail.test.js +2 -0
  19. package/src/commons/UnitSummary/ConfigHistoryChart/index.js +15 -16
  20. package/src/configs/API.js +1 -0
  21. package/src/configs/AccessibilityLabel.js +2 -0
  22. package/src/configs/Colors.js +1 -0
  23. package/src/hooks/IoT/__test__/useWatchConfigs.test.js +1 -0
  24. package/src/hooks/IoT/useWatchConfigs.js +3 -1
  25. package/src/iot/mqtt.js +23 -9
  26. package/src/screens/Automate/AddNewAction/ChooseAction.js +10 -0
  27. package/src/screens/Automate/ScriptDetail/index.js +2 -1
  28. package/src/screens/Device/__test__/mqttDetail.test.js +33 -20
  29. package/src/screens/Device/components/SensorDisplayItem.js +1 -0
  30. package/src/screens/Device/detail.js +25 -19
  31. package/src/screens/Device/hooks/useDeviceWatchConfigControl.js +4 -10
  32. package/src/utils/I18n/translations/en.js +1 -1
  33. package/src/utils/I18n/translations/vi.js +1 -1
@@ -500,29 +500,34 @@ const DeviceDetail = ({ route }) => {
500
500
  useFocusEffect(
501
501
  useCallback(() => {
502
502
  let params = new URLSearchParams();
503
- let configIds = [];
504
- // todo Bang refactor widgets like dashboard
505
- display.items.map((item) => {
506
- if (!item.configuration) {
503
+ let configIdsSet = new Set();
504
+
505
+ display.items.forEach((item) => {
506
+ const { configuration } = item;
507
+
508
+ if (!configuration) {
507
509
  return;
508
510
  }
509
- item.configuration.configs?.map((config) => {
510
- if (!configIds.includes(config.id)) {
511
- configIds.push(config.id);
512
- }
513
- });
514
- item.configuration.options?.map((option) => {
515
- if (!configIds.includes(option.config)) {
516
- configIds.push(option.config);
517
- }
518
- });
519
- if (item.configuration.config) {
520
- const config = item.configuration.config;
521
- const configId = config?.id ? config?.id : config;
522
- !configIds.includes(configId) && configIds.push(configId);
511
+
512
+ const { configs, options, config, from_config, to_config } =
513
+ configuration;
514
+
515
+ configs?.forEach((config) => configIdsSet.add(config.id));
516
+ options?.forEach((option) => configIdsSet.add(option.config));
517
+
518
+ if (config) {
519
+ const configId = config.id || config;
520
+ configIdsSet.add(configId);
521
+ }
522
+ if (from_config) {
523
+ configIdsSet.add(from_config.id);
524
+ }
525
+ if (to_config) {
526
+ configIdsSet.add(to_config.id);
523
527
  }
524
528
  });
525
529
 
530
+ let configIds = Array.from(configIdsSet);
526
531
  configIds = configIds.filter(Boolean);
527
532
  configIdsTemp.current = configIds;
528
533
 
@@ -610,7 +615,7 @@ const DeviceDetail = ({ route }) => {
610
615
  }, [display.items, isNetworkConnected, sensor, mqttConfigs])
611
616
  );
612
617
 
613
- useWatchConfigs(configIdsTemp.current);
618
+ useWatchConfigs(chipFiltered.length ? [] : configIdsTemp.current);
614
619
 
615
620
  const isShowEmergencyResolve =
616
621
  display.items.filter(
@@ -746,6 +751,7 @@ const DeviceDetail = ({ route }) => {
746
751
  }
747
752
  showWindDirection={showWindDirection}
748
753
  isDeviceHasBle={isDeviceHasBle}
754
+ key={`sensor${sensor.id}`}
749
755
  >
750
756
  {display.items.map((item, index) => {
751
757
  return (
@@ -8,12 +8,11 @@ export const useDeviceWatchConfigControl = (
8
8
  display,
9
9
  mqttConfigs = {}
10
10
  ) => {
11
+ const { is_managed_by_backend, device_type } = device;
11
12
  const configsNeedWatching = useMemo(() => {
12
13
  if (
13
- !device?.is_managed_by_backend ||
14
- [DEVICE_TYPE.GOOGLE_HOME, DEVICE_TYPE.LG_THINQ].includes(
15
- device?.device_type
16
- )
14
+ !is_managed_by_backend ||
15
+ [DEVICE_TYPE.GOOGLE_HOME, DEVICE_TYPE.LG_THINQ].includes(device_type)
17
16
  ) {
18
17
  return [];
19
18
  }
@@ -24,11 +23,6 @@ export const useDeviceWatchConfigControl = (
24
23
  );
25
24
  }
26
25
  return configsControl;
27
- }, [
28
- mqttConfigs,
29
- device?.device_type,
30
- device?.is_managed_by_backend,
31
- display,
32
- ]);
26
+ }, [is_managed_by_backend, device_type, display, mqttConfigs]);
33
27
  useWatchConfigs(configsNeedWatching);
34
28
  };
@@ -1467,7 +1467,7 @@ export default {
1467
1467
  'customize...': 'Customize...',
1468
1468
  uri_invalid: 'URI invalid',
1469
1469
  when_value_is: 'When value is',
1470
- template_not_supported: '"{template}" not yet supported',
1470
+ template_not_supported: 'Widget "{template}" not yet supported',
1471
1471
  invited_user: 'Invited user {user}',
1472
1472
  enter_value: 'Enter value',
1473
1473
  enter_parameters: 'Enter parameters',
@@ -1477,7 +1477,7 @@ export default {
1477
1477
  'customize...': 'Tùy chỉnh...',
1478
1478
  uri_invalid: 'URI không hợp lệ',
1479
1479
  when_value_is: 'Khi giá trị là',
1480
- template_not_supported: '"{template}" chưa được hỗ trợ',
1480
+ template_not_supported: 'Tiện ích "{template}" chưa được hỗ trợ',
1481
1481
  invited_user: 'Đã mời người dùng {user}',
1482
1482
  enter_value: 'Nhập giá trị',
1483
1483
  enter_parameters: 'Nhập thông số',