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:
@@ -102,6 +102,8 @@ function showDeviceSettings(deviceId: string): void {
|
|||||||
const token = getToken();
|
const token = getToken();
|
||||||
if (!token) return;
|
if (!token) return;
|
||||||
|
|
||||||
|
let deviceType: any;
|
||||||
|
|
||||||
fetch(`/api/devices/${deviceId}`, {
|
fetch(`/api/devices/${deviceId}`, {
|
||||||
headers: { Authorization: `Bearer ${token}` },
|
headers: { Authorization: `Bearer ${token}` },
|
||||||
})
|
})
|
||||||
@@ -115,7 +117,7 @@ function showDeviceSettings(deviceId: string): void {
|
|||||||
if (syncFrequencyInput)
|
if (syncFrequencyInput)
|
||||||
syncFrequencyInput.value = String(device.sync_frequency_minutes || 60);
|
syncFrequencyInput.value = String(device.sync_frequency_minutes || 60);
|
||||||
|
|
||||||
const deviceType = device.device_type;
|
deviceType = device.device_type;
|
||||||
return fetch("/api/collections", {
|
return fetch("/api/collections", {
|
||||||
headers: { Authorization: `Bearer ${token}` },
|
headers: { Authorization: `Bearer ${token}` },
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ function autoLinkBook(
|
|||||||
body: JSON.stringify(data),
|
body: JSON.stringify(data),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then((result) => {
|
.then(() => {
|
||||||
showToast("Book linked successfully", "success");
|
showToast("Book linked successfully", "success");
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
})
|
})
|
||||||
@@ -267,7 +267,7 @@ function confirmManualLink(): void {
|
|||||||
body: JSON.stringify(data),
|
body: JSON.stringify(data),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then((result) => {
|
.then(() => {
|
||||||
showToast("Book linked successfully", "success");
|
showToast("Book linked successfully", "success");
|
||||||
hideManualLinkModal();
|
hideManualLinkModal();
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
|
|||||||
Reference in New Issue
Block a user