Remove dset/dlv. Use lodash instead.

This commit is contained in:
Dermot Duffy
2022-01-14 21:31:16 -08:00
parent a9539925ca
commit a15ea2af45
4 changed files with 6 additions and 15 deletions
-2
View File
@@ -22,8 +22,6 @@
"@material/rtl": "^13.0.0",
"custom-card-helpers": "^1.8.0",
"dayjs": "^1.10.7",
"dlv": "github:developit/dlv",
"dset": "^3.1.1",
"embla-carousel": "^5.0.1",
"home-assistant-js-websocket": "^5.11.1",
"lit": "^2.0.2",
-2
View File
@@ -1,7 +1,5 @@
// TODO different live configs per camera
// TODO replace dset/dlv with lodash
// TODO evaluate single override section instead of per-subcomponent
// TODO fix adaptive height in fullscreen
// TODO Remove id as a concept for cameras and use an array instead?
// TODO Convert menu condition to use overrides
// TODO Remove media load event console message
+4 -9
View File
@@ -1,5 +1,4 @@
import delve from 'dlv';
import { dset } from 'dset';
import { get, set } from 'lodash-es';
import {
CONF_CAMERAS,
CONF_CAMERAS_ARRAY_CAMERA_ENTITY,
@@ -36,7 +35,7 @@ export const setConfigValue = (
keys: string | (string | number)[],
value: unknown,
): void => {
dset(obj, keys, value);
set(obj, keys, value)
};
/**
@@ -50,11 +49,7 @@ export const getConfigValue = (
keys: string | (string | number)[],
def?: unknown,
): unknown => {
// Need to manually split the key apart to use delve array accesses by number.
if (typeof keys === 'string') {
keys = keys.split('.');
}
return delve(obj, keys, def);
return get(obj, keys, def);
};
/**
@@ -172,7 +167,7 @@ export const moveConfigValue = (
* @returns The true config path.
*/
export const getArrayConfigPath = (path: string, index: number): string => {
return path.replace('#', index.toString());
return path.replace('#', `[${index.toString()}]`);
};
/**
+2 -2
View File
@@ -211,10 +211,10 @@ export class FrigateCardEditor extends LitElement implements LovelaceCardEditor
* @returns A localized label.
*/
protected _getLabel(configPath: string): string {
// Strip out single number path components as they are array indicies.
// Strip out array indices from the path.
const path = configPath
.split('.')
.filter((e) => isNaN(Number(e)))
.filter((e) => !e.match(/^\[[0-9]+\]$/))
.join('.');
return localize(`config.${path}`);
}