Skip to content

Commit a37717d

Browse files
committed
fix the flashing front page that has been there for months yeee~
1 parent 2c9cc5b commit a37717d

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

‎src/pages/Dashboard/index.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ export default function Dashboard() {
8585
fetchDailyTotalsRange,
8686
fetchWeekComparison,
8787
loading,
88+
hasLoaded,
8889
periodMode,
8990
setPeriodMode,
9091
todayTotals,
@@ -436,7 +437,7 @@ export default function Dashboard() {
436437
</div>
437438
</div>
438439

439-
{loading && (
440+
{loading && !hasLoaded && (
440441
<AsyncStateCard variant="loading" title={t("common:loading")} compact />
441442
)}
442443

‎src/stores/statsStore.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ interface StatsState {
2626
monitorStatus: MonitorStatus;
2727
currentApp: string;
2828
loading: boolean;
29+
hasLoaded: boolean;
2930
selectedDate: string;
3031
periodMode: PeriodMode;
3132
weekComparison: AppUsageComparison[];
@@ -81,6 +82,7 @@ export const useStatsStore = create<StatsState>((set, get) => ({
8182
monitorStatus: { active: true, current_app: "", current_exe_path: "", current_title: "" },
8283
currentApp: "",
8384
loading: false,
85+
hasLoaded: false,
8486
selectedDate: todayStr(),
8587
periodMode: "day",
8688
weekComparison: [],
@@ -111,7 +113,7 @@ export const useStatsStore = create<StatsState>((set, get) => ({
111113
} catch (e) {
112114
console.error("fetchToday failed", e);
113115
} finally {
114-
set({ loading: false });
116+
set({ loading: false, hasLoaded: true });
115117
}
116118
},
117119

@@ -144,7 +146,7 @@ export const useStatsStore = create<StatsState>((set, get) => ({
144146
console.error("fetchForDate failed", e);
145147
set({ todayTotals: [], todayHourly: [], totalSecondsToday: 0 });
146148
} finally {
147-
set({ loading: false });
149+
set({ loading: false, hasLoaded: true });
148150
}
149151
},
150152

@@ -169,7 +171,7 @@ export const useStatsStore = create<StatsState>((set, get) => ({
169171
} catch (e) {
170172
console.error("fetchForRange failed", e);
171173
} finally {
172-
set({ loading: false });
174+
set({ loading: false, hasLoaded: true });
173175
}
174176
},
175177

0 commit comments

Comments
 (0)