From 289c380a6ad4836fcb1fbfe8ff503ebe9cae0841 Mon Sep 17 00:00:00 2001 From: Paul Bottein Date: Mon, 10 Jul 2023 12:30:03 +0200 Subject: [PATCH] Remove unused device class translations (#17253) --- src/data/logbook.ts | 67 ++--------------------------------------- src/data/translation.ts | 1 - 2 files changed, 2 insertions(+), 66 deletions(-) diff --git a/src/data/logbook.ts b/src/data/logbook.ts index f5caa718b7..37b0737bea 100644 --- a/src/data/logbook.ts +++ b/src/data/logbook.ts @@ -71,71 +71,8 @@ export const getLogbookDataForContext = async ( hass: HomeAssistant, startDate: string, contextId?: string -): Promise => { - await hass.loadBackendTranslation("device_class"); - return getLogbookDataFromServer( - hass, - startDate, - undefined, - undefined, - contextId - ); -}; - -export const getLogbookData = async ( - hass: HomeAssistant, - startDate: string, - endDate: string, - entityIds?: string[], - deviceIds?: string[] -): Promise => { - await hass.loadBackendTranslation("device_class"); - return deviceIds?.length - ? getLogbookDataFromServer( - hass, - startDate, - endDate, - entityIds, - undefined, - deviceIds - ) - : getLogbookDataCache(hass, startDate, endDate, entityIds); -}; - -const getLogbookDataCache = async ( - hass: HomeAssistant, - startDate: string, - endDate: string, - entityId?: string[] -) => { - const ALL_ENTITIES = "*"; - - const entityIdKey = entityId ? entityId.toString() : ALL_ENTITIES; - const cacheKey = `${startDate}${endDate}`; - - if (!DATA_CACHE[cacheKey]) { - DATA_CACHE[cacheKey] = {}; - } - - if (entityIdKey in DATA_CACHE[cacheKey]) { - return DATA_CACHE[cacheKey][entityIdKey]!; - } - - if (entityId && DATA_CACHE[cacheKey][ALL_ENTITIES]) { - const entities = await DATA_CACHE[cacheKey][ALL_ENTITIES]!; - return entities.filter( - (entity) => entity.entity_id && entityId.includes(entity.entity_id) - ); - } - - DATA_CACHE[cacheKey][entityIdKey] = getLogbookDataFromServer( - hass, - startDate, - endDate, - entityId - ); - return DATA_CACHE[cacheKey][entityIdKey]!; -}; +): Promise => + getLogbookDataFromServer(hass, startDate, undefined, undefined, contextId); const getLogbookDataFromServer = ( hass: HomeAssistant, diff --git a/src/data/translation.ts b/src/data/translation.ts index b64e557b6b..99a7f7b521 100644 --- a/src/data/translation.ts +++ b/src/data/translation.ts @@ -67,7 +67,6 @@ export type TranslationCategory = | "device_automation" | "mfa_setup" | "system_health" - | "device_class" | "application_credentials" | "issues" | "selector";