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
This commit is contained in:
2026-03-13 22:25:31 -04:00
parent af7533529c
commit 855cbd1b74
2 changed files with 5 additions and 3 deletions
+3 -1
View File
@@ -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}` },
});
+2 -2
View File
@@ -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();