From e892ce9d9c934aa414022348e602ea1262fa9bef Mon Sep 17 00:00:00 2001 From: stfrigerio Date: Sat, 5 Apr 2025 17:56:01 +0200 Subject: [PATCH] smol cleanup --- src/webcomponents/BooleanSwitch/data/upsertBooleanValue.ts | 2 -- .../BooleanSwitch/eventHandlers/changeHandler.ts | 5 ----- 2 files changed, 7 deletions(-) diff --git a/src/webcomponents/BooleanSwitch/data/upsertBooleanValue.ts b/src/webcomponents/BooleanSwitch/data/upsertBooleanValue.ts index f2862d1..2c25f03 100644 --- a/src/webcomponents/BooleanSwitch/data/upsertBooleanValue.ts +++ b/src/webcomponents/BooleanSwitch/data/upsertBooleanValue.ts @@ -43,7 +43,5 @@ export async function upsertBooleanValue(instance: UpsertBooleanComponentInstanc console.error(`[UpsertBooleanValue ${instance.habitKey}] Failed to upsert data:`, error); instance.showErrorState("Save Error - DB"); new Notice(`Error saving switch state for ${instance.habitKey}`); - //? Optional: Revert display on error? - // instance._updateDisplay(instance.currentValue); } } \ No newline at end of file diff --git a/src/webcomponents/BooleanSwitch/eventHandlers/changeHandler.ts b/src/webcomponents/BooleanSwitch/eventHandlers/changeHandler.ts index 657e4b1..184adb8 100644 --- a/src/webcomponents/BooleanSwitch/eventHandlers/changeHandler.ts +++ b/src/webcomponents/BooleanSwitch/eventHandlers/changeHandler.ts @@ -10,14 +10,9 @@ export type ChangeEventHandler = (event: Event) => void; /** Creates the handler for the checkbox's 'change' event. */ export function createChangeHandler(instance: BooleanSwitchInstance): ChangeEventHandler { return (event: Event) => { - //? We don't actually need the event target's value, - //? the component's _updateData method will flip the *current* state. instance._updateData().catch(err => { - //? Error logging, specific handling is inside _updateData console.error(`[BooleanSwitchChangeHandler ${instance.habitKey}] Error during update:`, err); - //? Consider reverting the checkbox state visually if update fails? Requires more complex state management. if (event.target instanceof HTMLInputElement) { - // Example: Revert visual state - CAUTION: might fight with error state UI event.target.checked = !event.target.checked; } });