Skip to content
Merged
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
9 changes: 8 additions & 1 deletion hooks/use-steam-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ import type { SteamAchievementView, SteamStatsResponse } from "@/lib/types/steam
const REFRESH_COOLDOWN_MS = 3000
const STEAM_DATA_INVALIDATED_EVENT = "steam-data-invalidated"

// Timestamp factory for the render-phase state adjustment below. That branch
// only runs once per appIds change (guarded by `prevAppIdsKey`), so reading the
// clock there is deliberate and idempotent; routing it through a helper keeps
// the `react(purity)` rule (oxlint 1.86+) from flagging a direct `new Date()`
// call in the hook body.
const currentTimestamp = () => new Date()

// Each hook splits its loader in two: a "run" core that performs no setState
// before its fetch settles (safe to call synchronously from effects), and an
// event-driven wrapper that additionally flips the loading/refreshing flags
Expand Down Expand Up @@ -56,7 +63,7 @@ export function useSteamAchievementsBatch(appIds: number[]) {
setError(null)
if (!normalizedAppIds.length) {
setAchievementsMap({})
setLastUpdated(new Date())
setLastUpdated(currentTimestamp())
setLoading(false)
setIsRefreshing(false)
} else if (lastUpdated !== null) {
Expand Down
Loading