From eca90822e6d2a2726dae62aadee7587fdb35b971 Mon Sep 17 00:00:00 2001 From: Florent Benoit Date: Wed, 18 Dec 2024 18:16:50 +0100 Subject: [PATCH] chore: handle more cases where methods can be mocked Signed-off-by: Florent Benoit --- packages/renderer/src/TelemetryService.ts | 2 +- packages/renderer/src/stores/appearance.ts | 6 +++--- packages/renderer/src/stores/context.ts | 2 +- .../renderer/src/stores/navigation/navigation-registry.ts | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/renderer/src/TelemetryService.ts b/packages/renderer/src/TelemetryService.ts index 41e869f2b..b77b1ff74 100644 --- a/packages/renderer/src/TelemetryService.ts +++ b/packages/renderer/src/TelemetryService.ts @@ -37,7 +37,7 @@ export class TelemetryService { this.handlerFlusher = setTimeout(() => { if (window.telemetryPage) { - window.telemetryPage(pagePath).catch((error: unknown) => { + window.telemetryPage(pagePath)?.catch((error: unknown) => { console.error('Failed to send page event', error); }); } diff --git a/packages/renderer/src/stores/appearance.ts b/packages/renderer/src/stores/appearance.ts index bd2149610..d324ce4f9 100644 --- a/packages/renderer/src/stores/appearance.ts +++ b/packages/renderer/src/stores/appearance.ts @@ -26,13 +26,13 @@ export const isDark: Writable = writable(false); configurationProperties.subscribe(() => { if (window?.getConfigurationValue) { window - .getConfigurationValue(AppearanceSettings.SectionName + '.' + AppearanceSettings.Appearance) - .then(value => { + ?.getConfigurationValue(AppearanceSettings.SectionName + '.' + AppearanceSettings.Appearance) + ?.then(value => { if (value) { updateIsDark(value); } }) - .catch((err: unknown) => + ?.catch((err: unknown) => console.error( `Error getting configuration value ${AppearanceSettings.SectionName + '.' + AppearanceSettings.Appearance}`, err, diff --git a/packages/renderer/src/stores/context.ts b/packages/renderer/src/stores/context.ts index 4d1cb2535..5eb5c11ec 100644 --- a/packages/renderer/src/stores/context.ts +++ b/packages/renderer/src/stores/context.ts @@ -46,7 +46,7 @@ export function setup(): Writable { // this function can be undefined during tests window .contextCollectAllValues?.() - .then(values => { + ?.then(values => { const currentContext = Object.entries(values).reduce((result, [key, value]) => { result.setValue(key, value); return result; diff --git a/packages/renderer/src/stores/navigation/navigation-registry.ts b/packages/renderer/src/stores/navigation/navigation-registry.ts index 11ba2c398..131785241 100644 --- a/packages/renderer/src/stores/navigation/navigation-registry.ts +++ b/packages/renderer/src/stores/navigation/navigation-registry.ts @@ -154,7 +154,7 @@ configurationProperties.subscribe(() => { if (window.getConfigurationValue) { window .getConfigurationValue('navbar.disabledItems') - .then(value => { + ?.then(value => { if (value) { hiddenItems = value; }