From e65de207c0908c5857a99dbb15d357eb68627a36 Mon Sep 17 00:00:00 2001 From: alex Date: Sun, 6 Aug 2023 18:16:24 +0000 Subject: [PATCH] added duplicate item - bug with reference to old action - low prio --- .../Device/modals/EditActions/Lights/index.js | 37 +++++++++++++++++-- src/Screens/Device/scene.js | 5 ++- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/src/Screens/Device/modals/EditActions/Lights/index.js b/src/Screens/Device/modals/EditActions/Lights/index.js index 2b125c7..d81ceef 100644 --- a/src/Screens/Device/modals/EditActions/Lights/index.js +++ b/src/Screens/Device/modals/EditActions/Lights/index.js @@ -14,7 +14,12 @@ import { import Card from "../../../../../Components/Card"; import MyDropdown from "../../../../../Components/Dropdown"; import { useCallback, useContext, useEffect, useRef, useState } from "react"; -import { AppContext, AppStyles, ModalContainer } from "../../../../../utils"; +import { + AppContext, + AppStyles, + GetUuid, + ModalContainer, +} from "../../../../../utils"; import { MyDotsModal, MyPickerModalListItem, @@ -89,13 +94,31 @@ export function LightsEditActionModalContent({ navigation, route }) { headerRight: () => ( if the color is changed it will apply on both actions + icon: "content-duplicate", label: t( "screens.device.scenes.modalDotsEditAction.duplicateAction" ), - onPress: () => {}, - }, + onPress: () => { + const currentSelectedAction = + appContext.deviceSceneActions.find( + (a) => a.actionId === actionId + ); + + appContext.setDeviceSceneActions((arr) => { + const duplicatedAction = { + ...currentSelectedAction, + actionId: GetUuid(), + }; + + return [...arr, duplicatedAction]; + }); + + navigation.goBack(); + }, + },*/ { icon: "trash-can", label: t( @@ -157,6 +180,12 @@ export function LightsEditActionModalContent({ navigation, route }) { (a) => a.actionId === selectedSceneAction.actionId ); + console.log( + "foundSceneActionIndex", + foundSceneActionIndex, + newArr[foundSceneActionIndex] + ); + if (foundSceneActionIndex !== -1) { newArr[foundSceneActionIndex].modeAdjustments.colors = sharedLightModeDefaultColors.value; diff --git a/src/Screens/Device/scene.js b/src/Screens/Device/scene.js index 809f5b7..f1b6982 100644 --- a/src/Screens/Device/scene.js +++ b/src/Screens/Device/scene.js @@ -131,6 +131,7 @@ export default function SceneView({ navigation }) { return ( <> + {console.log("actions", appContext.deviceSceneActions)} {device.selectedScene === "" ? ( <> @@ -255,13 +256,13 @@ function ActionListItem({ drag, navigation, device, item }) { {appContext.deviceFirmwareModes.lightModes.find( (lM) => lM.id === item.modeId ).defaults.length === 0 - ? t( + ? `${t( "screens.device.scenes.sceneActionsListItems.layers.applyToLayers", { LAYER_GRAMMAR_FORM: layerGrammarForm, AFFECTED_LAYERS: affectedLayers, } - ) + )} ` : `${t( "screens.device.scenes.sceneActionsListItems.layers.setLayersTo", {