Skip to content

Commit c6479bc

Browse files
committed
Handle content state loading failures and add timeout for loading screen
1 parent 171a703 commit c6479bc

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

src/hoverboard-app.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Success } from '@abraham/remotedata';
1+
import { Failure, Success } from '@abraham/remotedata';
22
import '@polymer/app-layout/app-drawer-layout/app-drawer-layout';
33
import '@polymer/app-layout/app-drawer/app-drawer';
44
import { AppDrawerElement } from '@polymer/app-layout/app-drawer/app-drawer';
@@ -267,7 +267,9 @@ export class HoverboardApp extends PolymerElement {
267267

268268
@computed('contentState')
269269
private get contentStateSuccess() {
270-
return this.contentState instanceof Success;
270+
// Allow the app to load even if contentState fails or doesn't exist
271+
// This prevents the loading screen from staying indefinitely
272+
return this.contentState instanceof Success || this.contentState instanceof Failure;
271273
}
272274

273275
stateChanged(state: RootState) {
@@ -276,6 +278,11 @@ export class HoverboardApp extends PolymerElement {
276278
this.routeName = selectRouteName(window.location.pathname);
277279
this.user = state.user;
278280
this.signedIn = state.user instanceof Success;
281+
282+
// Debug logging for content state
283+
if (this.contentState instanceof Failure) {
284+
console.warn('Content state failed to load:', this.contentState.error);
285+
}
279286
}
280287

281288
constructor() {
@@ -290,6 +297,15 @@ export class HoverboardApp extends PolymerElement {
290297
this.drawer.addEventListener('opened-changed', (event) => this.toggleDrawer(event));
291298
store.dispatch(fetchTickets);
292299
store.dispatch(fetchContentState);
300+
301+
// Safety timeout: hide loading screen after 5 seconds even if content state hasn't loaded
302+
setTimeout(() => {
303+
if (!(this.contentState instanceof Success) && !(this.contentState instanceof Failure)) {
304+
console.warn('Content state timed out, allowing app to load anyway');
305+
// Force a state update to hide the loading screen
306+
this.contentState = new Failure(new Error('Content state load timeout'));
307+
}
308+
}, 5000);
293309
}
294310

295311
override ready() {

0 commit comments

Comments
 (0)