added duplicate item - bug with reference to old action - low prio

main
alex 2023-08-06 18:16:24 +00:00
parent 7ffb26c9a5
commit e65de207c0
2 changed files with 36 additions and 6 deletions

View File

@ -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: () => (
<MyDotsModal
modalData={[
{
/*{
Duplicated item as references to the old action -> 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;

View File

@ -131,6 +131,7 @@ export default function SceneView({ navigation }) {
return (
<>
{console.log("actions", appContext.deviceSceneActions)}
{device.selectedScene === "" ? (
<>
<DropdownCard />
@ -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",
{