From 855cbd1b744f10aa4f21f7c065e0e7f3392c33d3 Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Fri, 13 Mar 2026 22:25:31 -0400 Subject: [PATCH] fix(ts): resolve variable scoping and unused parameters in device management Fix TypeScript issues in device-management.ts and unlinked_books.ts: 1. device-management.ts: - Move 'deviceType' variable declaration to function scope in showDeviceSettings() - Previously declared inside a Promise chain, creating potential scope issues - Now properly declared at function level before async operations 2. unlinked_books.ts: - Remove unused 'result' parameter from .then() handlers - Fixes autoLinkBook() and confirmManualLink() functions - Handlers don't use the API response result, only need success/failure These changes improve code clarity and resolve potential runtime issues with variable accessibility in async callback chains. Technical details: - deviceType: moved from Promise .then() block to function scope - Unused parameters: removed to prevent linting warnings and improve clarity --- web/src/device-management.ts | 4 +++- web/src/unlinked_books.ts | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/web/src/device-management.ts b/web/src/device-management.ts index e59c70b..cd62f8e 100644 --- a/web/src/device-management.ts +++ b/web/src/device-management.ts @@ -102,6 +102,8 @@ function showDeviceSettings(deviceId: string): void { const token = getToken(); if (!token) return; + let deviceType: any; + fetch(`/api/devices/${deviceId}`, { headers: { Authorization: `Bearer ${token}` }, }) @@ -115,7 +117,7 @@ function showDeviceSettings(deviceId: string): void { if (syncFrequencyInput) syncFrequencyInput.value = String(device.sync_frequency_minutes || 60); - const deviceType = device.device_type; + deviceType = device.device_type; return fetch("/api/collections", { headers: { Authorization: `Bearer ${token}` }, }); diff --git a/web/src/unlinked_books.ts b/web/src/unlinked_books.ts index aecd481..069446b 100644 --- a/web/src/unlinked_books.ts +++ b/web/src/unlinked_books.ts @@ -105,7 +105,7 @@ function autoLinkBook( body: JSON.stringify(data), }) .then((response) => response.json()) - .then((result) => { + .then(() => { showToast("Book linked successfully", "success"); window.location.reload(); }) @@ -267,7 +267,7 @@ function confirmManualLink(): void { body: JSON.stringify(data), }) .then((response) => response.json()) - .then((result) => { + .then(() => { showToast("Book linked successfully", "success"); hideManualLinkModal(); window.location.reload();