style(web): fix async/await formatting in library.ts
Minor code formatting improvements to improve readability and consistency with TypeScript best practices. Changes (web/src/library.ts): 1. Fix async/await formatting (line 46-48): Before: const result = handleResponse(response) as unknown as LibrariesResponse; After: const result = (await handleResponse(response)) as unknown as LibrariesResponse; Properly wraps the async handleResponse call in parentheses before the type assertion, making the await precedence explicit. 2. Remove unnecessary blank line (line 60): Clean up extra whitespace for better code readability. These are pure formatting changes with no functional impact. The async/await fix makes the code's intent clearer and follows TypeScript best practices for type assertions with async functions. TypeScript: Type assertions with async functions
This commit is contained in:
+3
-2
@@ -43,7 +43,9 @@ let libraries: Library[] = [];
|
|||||||
async function reloadLibraries(): Promise<void> {
|
async function reloadLibraries(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const response = await apiGet("/libraries");
|
const response = await apiGet("/libraries");
|
||||||
const result = handleResponse(response) as unknown as LibrariesResponse;
|
const result = (await handleResponse(
|
||||||
|
response,
|
||||||
|
)) as unknown as LibrariesResponse;
|
||||||
libraries = result.data;
|
libraries = result.data;
|
||||||
renderLibraries();
|
renderLibraries();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -55,7 +57,6 @@ async function reloadLibraries(): Promise<void> {
|
|||||||
function renderLibraries(): void {
|
function renderLibraries(): void {
|
||||||
const container = document.getElementById("libraries-list");
|
const container = document.getElementById("libraries-list");
|
||||||
if (!container) return;
|
if (!container) return;
|
||||||
|
|
||||||
if (libraries.length === 0) {
|
if (libraries.length === 0) {
|
||||||
container.innerHTML =
|
container.innerHTML =
|
||||||
'<p style="color: var(--text-secondary)" class="text-center py-8">No libraries yet. Create your first library to get started.</p>';
|
'<p style="color: var(--text-secondary)" class="text-center py-8">No libraries yet. Create your first library to get started.</p>';
|
||||||
|
|||||||
Reference in New Issue
Block a user