remove async from parseProperty

This commit is contained in:
arc-alex
2024-08-19 12:35:25 +02:00
parent a8bc4eb098
commit 31316a6661
2 changed files with 9 additions and 12 deletions
@@ -54,18 +54,15 @@ const actionHandlers: Record<string, ActionHandler> = {
if (typeof property !== 'string' || value === undefined) { if (typeof property !== 'string' || value === undefined) {
throw new Error('Invalid property or value'); throw new Error('Invalid property or value');
} }
// parseProperty is async because of the data lock // parseProperty is async because of the data lock
parseProperty(property, value).then((newObjectProperty) => { const newObjectProperty = parseProperty(property, value);
const key = Object.keys(newObjectProperty)[0] as keyof OntimeEvent; const key = Object.keys(newObjectProperty)[0] as keyof OntimeEvent;
shouldThrottle = willCauseRegeneration(key) || shouldThrottle; shouldThrottle = willCauseRegeneration(key) || shouldThrottle;
if (patchEvent.custom && newObjectProperty.custom) {
if (patchEvent.custom && newObjectProperty.custom) { Object.assign(patchEvent.custom, newObjectProperty.custom);
Object.assign(patchEvent.custom, newObjectProperty.custom); } else {
} else { Object.assign(patchEvent, newObjectProperty);
Object.assign(patchEvent, newObjectProperty); }
}
});
}); });
if (shouldThrottle) { if (shouldThrottle) {
@@ -42,7 +42,7 @@ const propertyConversion = {
timeEnd: (value: unknown) => clampDuration(coerceNumber(value)), timeEnd: (value: unknown) => clampDuration(coerceNumber(value)),
}; };
export async function parseProperty(property: string, value: unknown) { export function parseProperty(property: string, value: unknown) {
if (property.startsWith('custom:')) { if (property.startsWith('custom:')) {
const customKey = property.split(':')[1].toLocaleLowerCase(); // all custom fields keys are lowercase const customKey = property.split(':')[1].toLocaleLowerCase(); // all custom fields keys are lowercase
const customFields = getDataProvider().getCustomFields(); const customFields = getDataProvider().getCustomFields();