Remove unused device class translations (#17253)

This commit is contained in:
Paul Bottein 2023-07-10 12:30:03 +02:00 committed by GitHub
parent f35b493d2e
commit 289c380a6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 66 deletions

View File

@ -71,71 +71,8 @@ export const getLogbookDataForContext = async (
hass: HomeAssistant,
startDate: string,
contextId?: string
): Promise<LogbookEntry[]> => {
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<LogbookEntry[]> => {
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<LogbookEntry[]> =>
getLogbookDataFromServer(hass, startDate, undefined, undefined, contextId);
const getLogbookDataFromServer = (
hass: HomeAssistant,

View File

@ -67,7 +67,6 @@ export type TranslationCategory =
| "device_automation"
| "mfa_setup"
| "system_health"
| "device_class"
| "application_credentials"
| "issues"
| "selector";