Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,14 @@ export class HackerNewsApp {
showUpdateNotification(this.headerState, this.updateInfo);
}

startHeaderLoading() {
startLoadingAnimation(this.headerState, () => this.renderer.isDestroyed);
}

stopHeaderLoading() {
stopLoadingAnimation(this.headerState);
}

private setupLayout() {
const mainContainer = new BoxRenderable(this.ctx, {
width: "100%",
Expand Down Expand Up @@ -577,14 +585,12 @@ export class HackerNewsApp {
}

private async loadPosts() {
// Start loading animation (both header indicator and empty state animation)
startLoadingAnimation(this.headerState, () => this.renderer.isDestroyed);
// Start full-screen loading animation (header loading is reserved for update checks)
startEmptyStateAnimation(this.emptyStateState, "loading", () => this.renderer.isDestroyed);

try {
this.posts = await getRankedPosts();
this.storiesFetchedAt = Date.now();
stopLoadingAnimation(this.headerState);
stopEmptyStateAnimation(this.emptyStateState);

// Remove loading state and add the main layout
Expand All @@ -606,7 +612,6 @@ export class HackerNewsApp {

this.saveToCache();
} catch (error) {
stopLoadingAnimation(this.headerState);
stopEmptyStateAnimation(this.emptyStateState);
log("[ERROR]", "Error loading posts:", error);
}
Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ async function main() {
await app.initialize();

// Check for updates in the background (non-blocking)
app.startHeaderLoading();
checkForUpdates().then((updateInfo) => {
app.stopHeaderLoading();
if (updateInfo?.hasUpdate) {
app.setUpdateInfo(updateInfo);
}
Expand Down