refactor: clean up opal-web duplication, dead code, and comment noise

- Deduplicate API_BASE (was defined in both client.js and endpoints.js)
- Extract EMPTY_STATE and persist() helper in auth store (DRY)
- Extract updateByUuid() in tasks store, normalize to .map() pattern
- Remove unused getQueueSize(), Select.svelte, and lib/index.js
- Modernize uuid.js to prefer crypto.randomUUID()
- Strip ~60 redundant comments that restated self-evident code

No behavior changes. Build passes, pre-existing type errors unchanged.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-21 01:03:08 +01:00
parent 41a12fe7a9
commit 8693681660
22 changed files with 110 additions and 470 deletions
+1 -5
View File
@@ -6,7 +6,7 @@ import { get } from 'svelte/store';
* @typedef {import('./types.js').AuthTokens} AuthTokens
*/
const API_BASE = import.meta.env.VITE_API_URL || 'http://localhost:8080';
export const API_BASE = import.meta.env.VITE_API_URL || 'http://localhost:8080';
/**
* Make authenticated API request
@@ -23,7 +23,6 @@ export async function apiRequest(endpoint, options = {}) {
...options.headers
};
// Add auth token if available
if (auth.accessToken) {
headers['Authorization'] = `Bearer ${auth.accessToken}`;
}
@@ -34,11 +33,9 @@ export async function apiRequest(endpoint, options = {}) {
headers
});
// Token expired - try refresh
if (response.status === 401 && auth.refreshToken) {
const refreshed = await refreshAccessToken(auth.refreshToken);
if (refreshed) {
// Retry with new token
headers['Authorization'] = `Bearer ${refreshed.access_token}`;
return apiRequest(endpoint, { ...options, headers });
}
@@ -78,7 +75,6 @@ async function refreshAccessToken(refreshToken) {
const result = await response.json();
if (result.success) {
// Update auth store
authStore.setTokens(result.data);
return result.data;
}