updates changeCallback and SerializedObject in GenericComponent.tsx

This commit is contained in:
Mose Müller 2024-03-27 09:32:18 +01:00
parent 2eb996b382
commit 1a01222cb3

View File

@ -14,7 +14,7 @@ import { ColouredEnumComponent } from './ColouredEnumComponent';
import { LevelName } from './NotificationsComponent'; import { LevelName } from './NotificationsComponent';
import { getIdFromFullAccessPath } from '../utils/stringUtils'; import { getIdFromFullAccessPath } from '../utils/stringUtils';
import { WebSettingsContext } from '../WebSettings'; import { WebSettingsContext } from '../WebSettings';
import { setAttribute } from '../socket'; import { updateValue } from '../socket';
type AttributeType = type AttributeType =
| 'str' | 'str'
@ -34,6 +34,8 @@ type AttributeType =
type ValueType = boolean | string | number | Record<string, unknown>; type ValueType = boolean | string | number | Record<string, unknown>;
export type SerializedValue = { export type SerializedValue = {
type: AttributeType; type: AttributeType;
full_access_path: string;
name?: string;
value?: ValueType | ValueType[]; value?: ValueType | ValueType[];
readonly: boolean; readonly: boolean;
doc?: string | null; doc?: string | null;
@ -72,12 +74,10 @@ export const GenericComponent = React.memo(
} }
function changeCallback( function changeCallback(
value: unknown, value: SerializedValue,
attributeName: string = name,
prefix: string = parentPath,
callback: (ack: unknown) => void = undefined callback: (ack: unknown) => void = undefined
) { ) {
setAttribute(attributeName, prefix, value, callback); updateValue(value, callback);
} }
if (attribute.type === 'bool') { if (attribute.type === 'bool') {