Skip to content

Commit a3365ba

Browse files
committed
Added loading state.
1 parent 6ffefb6 commit a3365ba

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/app.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ export class App extends LitElement {
7676
@state()
7777
records: ExceptionListEntry[] = [];
7878

79+
@state()
80+
loading: boolean = true;
81+
7982
// Holds error message if fetching records fails.
8083
@state()
8184
error: string | null = null;
@@ -118,6 +121,7 @@ export class App extends LitElement {
118121
*/
119122
async init() {
120123
try {
124+
this.loading = true;
121125
this.records = await fetchRecords(RS_ENDPOINTS[this.rsEnv]);
122126

123127
// Spot check if the format is as expected.
@@ -130,6 +134,8 @@ export class App extends LitElement {
130134
this.error = null;
131135
} catch (error: any) {
132136
this.error = error?.message || "Failed to initialize";
137+
} finally {
138+
this.loading = false;
133139
}
134140
}
135141

@@ -150,6 +156,10 @@ export class App extends LitElement {
150156
return html`<div class="error">Error while processing records: ${this.error}</div>`;
151157
}
152158

159+
if (this.loading) {
160+
return html`<div>Loading...</div>`;
161+
}
162+
153163
if (this.records.length === 0) {
154164
return html`<div>No records found.</div>`;
155165
}

0 commit comments

Comments
 (0)