mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Refactor for reduced nesting
Signed-off-by: Iku-turso <mikko.aspiala@gmail.com> Co-authored-by: Gabriel <gaccettola@mirantis.com>
This commit is contained in:
parent
3931c90d30
commit
f3ecdddcb5
@ -27,20 +27,23 @@ const telemetryDecoratorInjectable = getInjectable({
|
|||||||
(di: DiContainerForInjection, instantiationParameter: any) => {
|
(di: DiContainerForInjection, instantiationParameter: any) => {
|
||||||
const instance = instantiateToBeDecorated(di, instantiationParameter);
|
const instance = instantiateToBeDecorated(di, instantiationParameter);
|
||||||
|
|
||||||
if (isFunction(instance)) {
|
if (!isFunction(instance)) {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
return (...args: any[]) => {
|
return (...args: any[]) => {
|
||||||
const currentContext = di.context.at(-1);
|
const currentContext = di.context.at(-1);
|
||||||
|
|
||||||
assert(currentContext);
|
assert(currentContext);
|
||||||
|
|
||||||
const emitTelemetry = diForDecorator.inject(
|
const emitTelemetry = diForDecorator.inject(
|
||||||
emitTelemetryInjectable,
|
emitTelemetryInjectable
|
||||||
);
|
);
|
||||||
|
|
||||||
const logError = diForDecorator.inject(logErrorInjectable);
|
const logError = diForDecorator.inject(logErrorInjectable);
|
||||||
|
|
||||||
const whiteList = diForDecorator.inject(
|
const whiteList = diForDecorator.inject(
|
||||||
telemetryWhiteListForFunctionsInjectable,
|
telemetryWhiteListForFunctionsInjectable
|
||||||
);
|
);
|
||||||
|
|
||||||
const whiteListMap = getWhiteListMap(whiteList);
|
const whiteListMap = getWhiteListMap(whiteList);
|
||||||
@ -60,7 +63,7 @@ const telemetryDecoratorInjectable = getInjectable({
|
|||||||
|
|
||||||
logError(
|
logError(
|
||||||
`Tried to produce params for telemetry of "${currentContext.injectable.id}", but getParams() threw an error`,
|
`Tried to produce params for telemetry of "${currentContext.injectable.id}", but getParams() threw an error`,
|
||||||
e,
|
e
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,9 +75,6 @@ const telemetryDecoratorInjectable = getInjectable({
|
|||||||
|
|
||||||
return instance(...args);
|
return instance(...args);
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
return instance;
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user